Skip to content

Instantly share code, notes, and snippets.

@fkaa
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save fkaa/34d468133d3937298da9 to your computer and use it in GitHub Desktop.

Select an option

Save fkaa/34d468133d3937298da9 to your computer and use it in GitHub Desktop.
import praw
from collections import defaultdict
reddit = praw.Reddit(user_agent='karma_scraper')
reddit.login('username', 'password')
subreddit = reddit.get_subreddit('combatfootage')
response = subreddit.get_top(limit=50)
results = defaultdict(int)
for val in response:
author = "[deleted]" if val.author is None else val.author.name
results[author] += val.score
for key, value in sorted(results.iteritems(), key=lambda (k,v): (v,k), reverse=True):
print "%s: %s" % (key, value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment