Created
July 2, 2010 19:09
-
-
Save jrabbit/461769 to your computer and use it in GitHub Desktop.
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
from urllib2 import urlopen | |
import simplejson as json | |
class Reddit: | |
def __init__(self): | |
self.url = 'http://www.reddit.com/user/%s/about.json' | |
def karma(self, phrase): | |
user = sys.argv[1] | |
raw = urlopen(self.url % phrase).read() | |
data = json.loads(raw)['data'] | |
karma = data['link_karma'] | |
comment = data['comment_karma'] | |
return [user, karma, comment, user] | |
if __name__ == '__main__': | |
import sys | |
if len(sys.argv) > 1: | |
phrase = sys.argv[1] | |
reddit = Reddit() | |
values = reddit.karma(phrase) | |
print "%s has %s link karma and %s comment karma: http://www.reddit.com/user/%s" % (values) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment