Browse Source

Update properties grabbed for both active use cases.

master
jowj 3 years ago
parent
commit
2084ea95d3
  1. 11
      main.py

11
main.py

@ -11,18 +11,17 @@ reddit = praw.Reddit(client_id=os.environ.get('REDDIT_ID'),
)
your_user = reddit.redditor(os.environ.get('REDDIT_UN'))
saved_posts = your_user.saved(limit=20)
saved_posts = your_user.saved(limit=50)
posts_to_save = []
for link in saved_posts:
if hasattr(link, 'is_self'):
posts_to_save.append([link.name, link.subreddit.display_name, link.author.name, link.selftext, link.title])
elif hasattr(link, 'is_root'):
posts_to_save.append([link.name, link.subreddit.display_name, link.body, link.author.name])
posts_to_save.append([link.title, link.subreddit.display_name, link.author.name, link.selftext, link.url, link.permalink])
elif hasattr(link, 'is_root'):
# pdb.set_trace()
posts_to_save.append([link.link_title, link.subreddit.display_name, link.author.name, link.body, link.link_url])
else:
pdb.set_trace()
with open('data.json', 'w') as outfile:
json.dump(posts_to_save, outfile, indent=2)

Loading…
Cancel
Save