Last active
March 19, 2016 20:22
-
-
Save 13steinj/4ee4031dc887a6c16e2e to your computer and use it in GitHub Desktop.
the thing for the guy that ppmeed me
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 | |
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