Created
April 25, 2018 04:02
-
-
Save yi-jiayu/b2e9f6ee45318dd2d9cc5aa5cfdeeed0 to your computer and use it in GitHub Desktop.
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
import praw | |
CLIENT_ID = 'YOUR_CLIENT_ID' | |
CLIENT_SECRET = 'YOUR_CLIENT_SECRET' | |
REDDIT_USERNAME = 'your reddit username' | |
# https://www.reddit.com/r/singapore/comments/8eoesx/rsingapore_random_discussion_and_small_questions/ | |
submission_id = '8eoesx' | |
reddit = praw.Reddit(client_id=CLIENT_ID, client_secret=CLIENT_SECRET, | |
user_agent='Markov Text Generation from Reddit Comments by /u/' + REDDIT_USERNAME) | |
submission = reddit.submission(id=submission_id) | |
submission.comments.replace_more(limit=None) | |
# here is our comment iterator | |
for comment in submission.comments.list(): | |
# Python 3.6 f-string syntax (https://www.python.org/dev/peps/pep-0498/) | |
print(f'{comment.author}: {comment.body}') | |
# pre-Python 3.6 | |
# print('{}: {}'.format(comment.author, comment.body)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment