Created
January 12, 2013 13:53
-
-
Save starenka/4518157 to your computer and use it in GitHub Desktop.
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 time | |
from pyquery import PyQuery as pq | |
def do(): | |
doc = pq('http://www.volby.cz/pls/prez2013/pe2?xjazyk=CZ') | |
perc = map(lambda x: float(x.text.replace(',','.')), doc.find('table.left2 td.cislo[headers="s2a6 s2b5"]')) | |
names = map(lambda x: x.text, doc.find('table.left2 td[headers="s2a1 s2b2"]')) | |
print '\nSECTENO %s%%\n' % doc.find('td[headers="s1a1 s1b3"]')[0].text | |
d = dict(zip(names, perc)) | |
for w in sorted(d, key=d.get, reverse=True): | |
print w, d[w] | |
while True: | |
do() | |
time.sleep(30) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment