Return to Snippet

Revision: 69252
at May 16, 2015 11:22 by karmakanadian


Initial Code
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')

Initial URL

                                

Initial Description
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.

Initial Title
Comment Scrape Test

Initial Tags

                                

Initial Language
Python