Created
November 7, 2012 02:55
-
-
Save carloe/4029327 to your computer and use it in GitHub Desktop.
Grabs the current electoral vote counts from huffingtonpost.com
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 | |
# encoding: utf-8 | |
import re | |
from urllib import urlopen | |
html = urlopen("http://elections.huffingtonpost.com/2012/results").read() | |
result = re.findall("<span class\\=\\\"obama-popular-votes-pct \\\"\\>([0-9]{3})\\<\\/span\\><\\/span\\>\\ \\;\\ \\; \\;\\<span class\\=\\\"gop\\\"\\><span class\\=\\\"romney-popular-votes-pct \\\"\\>([0-9]{3})\\<\\/span\\>", html, re.S) | |
print "Obama:\t" + result[0][0] | |
print "Romney:\t" + result[0][1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment