Skip to content

Instantly share code, notes, and snippets.

@jpadilla
Created November 13, 2012 11:19
Show Gist options
  • Save jpadilla/4065288 to your computer and use it in GitHub Desktop.
Save jpadilla/4065288 to your computer and use it in GitHub Desktop.
7 lines, no external requirements (7 lines, 28 words, 605 chars)
import urllib2
import lxml.etree as E
import time
print '\nGOVERNOR\nISLAND WIDE RESULTS\n'
while 1:
print '\n'.join(['%s\n'%E.fromstring(urllib2.urlopen('http://is.gd/wB6SJq').read()).find('date').text,'\n'.join(map(lambda e:'%s (%s) => %s (%s%%)'%e,[(o.find('name/es').text,o.find('pe/es').text,format(int(o.find('votes').text),',d'),str(float(o.find('votes').text)/sum([int(e.text)for e in E.fromstring(urllib2.urlopen('http://is.gd/wB6SJq').read()).findall('option/votes')])*100)[0:5])for o in E.fromstring(urllib2.urlopen('http://is.gd/wB6SJq').read()).findall('option')]))])
time.sleep(120)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment