Created
November 6, 2008 19:37
-
-
Save segphault/22684 to your computer and use it in GitHub Desktop.
Retrieve data from Google's election tracker
This file contains 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 | |
import simplejson, urllib2 | |
DATA_URL = "http://election2008.s3.amazonaws.com/votes/us-pres.json" | |
data = simplejson.loads(urllib2.urlopen(DATA_URL).read()) | |
for candidate in data["totals"]["races"]["President"][""]["votes"]: | |
name = data["candidates"][candidate["id"]].split("|")[1] | |
print "%s: %s - %s" % ( | |
name, candidate["votes"], candidate["electoral"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment