Advertisement
Guest User

Random username picker

a guest
Sep 2nd, 2015
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. import praw
  2. import random
  3.  
  4. r = praw.Reddit('Comment Scraper 1.0 by u/_Daimon_ see '
  5.                 'https://praw.readthedocs.org/en/latest/'
  6.                 'pages/comment_parsing.html')
  7. submission = r.get_submission(submission_id='3gqwl5')
  8.  
  9. submission.replace_more_comments(limit=None, threshold=0)
  10. allComments = submission.comments
  11. flatComments = praw.helpers.flatten_tree(allComments)
  12.  
  13. usernames = set()
  14. for comment in flatComments:
  15.     if comment.author is not None and comment.author.name not in usernames:
  16.             usernames.add(comment.author.name)
  17.  
  18. print(len(usernames))
  19.  
  20. print( random.sample(usernames, 1) )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement