-
-
Save kylethebaker/b81005b36c72c323aa3b to your computer and use it in GitHub Desktop.
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
#!/bin/python | |
import praw | |
import sys | |
# recursivly parse comments and MoreComments objects | |
def parse_comments(comments): | |
for comment in comments: | |
if isinstance(comment, praw.objects.MoreComments): | |
parse_comments(comment.comments()) | |
elif comment.is_root and comment.author is not None: | |
CONTESTANTS.add(str(comment.author)) | |
# make sure a submission id is given | |
if len(sys.argv) != 2: | |
print("usage: {} <submission_id>".format(sys.argv[0])) | |
sys.exit(1) | |
# create praw object and get submission contents if we have a valid id | |
r = praw.Reddit("local ecr giveaway extractor for fun by /u/kylebaked") | |
parameters = { | |
"submission_id": sys.argv[1], | |
"comment_limit": None, | |
"comment_sort": "old", | |
"params": {"depth": 1} | |
} | |
try: | |
submission = r.get_submission(**parameters) | |
except: | |
print("invalid submission id") | |
sys.exit(1) | |
CONTESTANTS = set() | |
parse_comments(submission.comments) | |
print(CONTESTANTS) | |
sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment