/ Published in: Python
Using this, I scrape all comments of a particular submission, and print them in a flat fashion. This is purely comment bodies, not usernames, karma, or any other meta data.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import time import praw r = praw.Reddit('[REDACTED]') already_done = [] submission = r.get_submission('http://www.reddit.com/r/learnprogramming/comments/362ark/how_are_reddit_bots_created/') submission.replace_more_comments(limit=30, threshold=10) flat_comments = praw.helpers.flatten_tree(submission.comments) while True: for comment in flat_comments: f = open('comments.txt', 'a') f.write(comment.body + '\n' + '+--------------------------------------------------------------------------------------------------------------------------+' + '\n')