Created
October 9, 2018 22:22
-
-
Save citostyle/283b785dc85cc0e0f092eb095b9ad6c1 to your computer and use it in GitHub Desktop.
Retrieve Reddit posts from a particular subreddit using the `praw` Python library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def extract_submissions(client_id, client_secret, user_agent, subreddit_name): | |
reddit = praw.Reddit(client_id=client_id, client_secret=client_secret, user_agent=user_agent) | |
subreddit = reddit.subreddit(subreddit_name) | |
submissions = [{'id': s.id, 'title': s.title, 'upvotes': s.ups, 'downvotes': s.downs, 'href': s.permalink, 'number_of_comments': s.num_comments, 'content': s.selftext} | |
for s in subreddit.hot(limit=None)] | |
return submissions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment