-
-
Save xjcl/c8286c812d90192b2d420b334df143d4 to your computer and use it in GitHub Desktop.
Subreddit flair stats
This file contains hidden or 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
#!/usr/bin/env python | |
# modified from https://gist.github.com/rasher/4208507 (python 2) | |
import sys | |
from datetime import datetime | |
from praw import Reddit | |
from collections import defaultdict | |
r = Reddit(user_agent='flairstats/0.1 by <YOUR USERNAME>', | |
client_id='<GET THESE AS DESCRIBED HERE:', client_secret='https://praw.readthedocs.io/en/latest/getting_started/quick_start.html>', | |
username='<YOUR USERNAME (THE ONE YOU ARE MOD WITH)>', password='<YOUR PASSWORD>') | |
stats = defaultdict(int) | |
for item in r.subreddit('chuggaaconroy').flair(): | |
stats[item['flair_css_class']] += 1 | |
for flair, count in sorted(stats.items(), key=lambda x: -x[1]): | |
print(" %5d (%5.1f%%) %s" % (count, float(count*100)/sum(stats.values()), flair)) | |
print(" %5d (100.0%%) %s" % (sum(stats.values()), "Total")) | |
print("*Updated %s*" % datetime.utcnow().strftime("%Y-%m-%d %H:%MZ (UTC)")) | |
# Example output: | |
# 107 ( 23.4%) steve40 | |
# 105 ( 23.0%) bowser-anim40 | |
# 94 ( 20.6%) stache30 | |
# 54 ( 11.8%) princess40 | |
# 43 ( 9.4%) nest34 | |
# 20 ( 4.4%) mario | |
# 16 ( 3.5%) rookie36 | |
# 8 ( 1.8%) bowletta35 | |
# 8 ( 1.8%) None | |
# 2 ( 0.4%) empty | |
# 457 (100.0%) Total | |
# *Updated 2018-07-16 22:09Z (UTC)* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment