Skip to content

Instantly share code, notes, and snippets.

@13steinj
Last active March 19, 2016 20:22
Show Gist options
  • Save 13steinj/4ee4031dc887a6c16e2e to your computer and use it in GitHub Desktop.
Save 13steinj/4ee4031dc887a6c16e2e to your computer and use it in GitHub Desktop.
the thing for the guy that ppmeed me
import praw
from praw.helpers import flatten_tree
import six
if six.PY2:
input = raw_input
r = praw.Reddit("Submission comments scraper")
r.login(disable_warning=True)
lim = 1500 if r.user.is_gold else 500
s = r.get_submission(input("Copypasta/type a submission url:\n"), comment_limit=lim)
print("Replacing more comments")
s.replace_more_comments(limit=None)
logfname = input("Choose a log filename:\n")
logfname = logfname + '.log' if not any(logfname.endswith(ending) for ending in ('.txt', '.log')) else logfname
commentdata = [comment.body for comment in flatten_tree(s.comments)]
with open(logfname, 'w') as f:
f.write("\n||=================================||\n".join(commentdata))
print("Done!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment