Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw, collections
- reddit = praw.Reddit(user_agent="Why do you care", client_id="Your Client ID", client_secret="Your Client Secret")
- subreddit = reddit.subreddit('politicalcompassmemes')
- flairCounter = collections.Counter()
- for i in subreddit.hot(limit=1000):
- commentQueue = i.comments.list()
- while commentQueue:
- comment = commentQueue.pop(0)
- if type(comment) == praw.models.reddit.more.MoreComments:
- commentQueue.extend(comment.comments())
- else:
- flairCounter[comment.author_flair_text] += 1
- commentQueue.extend(comment.replies)
- numComments = sum(flairCounter.values())
- for i in flairCounter.most_common():
- print(f"{i[0]}: {i[1]} comments ({(i[1] * 100 / numComments):.2f}% of all comments)")
- print(f'{numComments} comments made in total')
Add Comment
Please, Sign In to add comment