Guest User

Untitled

a guest
May 1st, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. import praw, collections
  2.  
  3. reddit = praw.Reddit(user_agent="Why do you care", client_id="Your Client ID", client_secret="Your Client Secret")
  4. subreddit = reddit.subreddit('politicalcompassmemes')
  5.  
  6. flairCounter = collections.Counter()
  7.  
  8. for i in subreddit.hot(limit=1000):
  9.     commentQueue = i.comments.list()
  10.     while commentQueue:
  11.         comment = commentQueue.pop(0)
  12.         if type(comment) == praw.models.reddit.more.MoreComments:
  13.             commentQueue.extend(comment.comments())
  14.         else:
  15.             flairCounter[comment.author_flair_text] += 1
  16.             commentQueue.extend(comment.replies)
  17.  
  18. numComments = sum(flairCounter.values())
  19.  
  20. for i in flairCounter.most_common():
  21.     print(f"{i[0]}: {i[1]} comments ({(i[1] * 100 / numComments):.2f}% of all comments)")
  22.  
  23. print(f'{numComments} comments made in total')
Add Comment
Please, Sign In to add comment