Posted By

karmakanadian on 05/16/15


Tagged

praw


Versions (?)

Comment Scrape Test


 / 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.

  1. import time
  2. import praw
  3.  
  4. r = praw.Reddit('[REDACTED]')
  5. already_done = []
  6. submission = r.get_submission('http://www.reddit.com/r/learnprogramming/comments/362ark/how_are_reddit_bots_created/')
  7. submission.replace_more_comments(limit=30, threshold=10)
  8. flat_comments = praw.helpers.flatten_tree(submission.comments)
  9.  
  10. while True:
  11. for comment in flat_comments:
  12. f = open('comments.txt', 'a')
  13. f.write(comment.body + '\n' + '+--------------------------------------------------------------------------------------------------------------------------+' + '\n')

Report this snippet  

You need to login to post a comment.