Created
November 13, 2012 11:19
-
-
Save jpadilla/4065288 to your computer and use it in GitHub Desktop.
Revisions
-
jpadilla revised this gist
Nov 13, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,5 +3,5 @@ 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) -
siloraptor revised this gist
Nov 13, 2012 . 1 changed file with 4 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,7 @@ 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://div1.ceepur.org/REYDI_NocheDelEvento/data/GOBERNADOR_ISLA.xml').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://div1.ceepur.org/REYDI_NocheDelEvento/data/GOBERNADOR_ISLA.xml').read()).findall('option/votes')])*100)[0:5])for o in E.fromstring(urllib2.urlopen('http://div1.ceepur.org/REYDI_NocheDelEvento/data/GOBERNADOR_ISLA.xml').read()).findall('option')]))]) time.sleep(120) -
siloraptor revised this gist
Nov 9, 2012 . 1 changed file with 3 additions and 10 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,13 +3,6 @@ import time print '\nGOVERNOR\nISLAND WIDE RESULTS\n', '-' * 19 while True: print '\n%s\n' % (parseString(urllib2.urlopen('http://div1.ceepur.org/REYDI_NocheDelEvento/data/GOBERNADOR_ISLA.xml').read()).getElementsByTagName('date')[0].childNodes[0].data) print '\n\n'.join(map(lambda entry: '%(name)s (%(party)s) => %(votes)s (%(percent)s%%)' % entry, [{'party': option.getElementsByTagName('pe')[0].getElementsByTagName('es')[0].childNodes[0].data.title(), 'name': option.getElementsByTagName('name')[0].getElementsByTagName('es')[0].childNodes[0].data, 'votes': format(int(option.getElementsByTagName('votes')[0].childNodes[0].data), ',d'), 'percent': format(float(option.getElementsByTagName('votes')[0].childNodes[0].data) / int(sum([int(option.getElementsByTagName('votes')[0].childNodes[0].data) for option in parseString(urllib2.urlopen('http://div1.ceepur.org/REYDI_NocheDelEvento/data/GOBERNADOR_ISLA.xml').read()).getElementsByTagName('option')])) * 100, '.3')} for option in parseString(urllib2.urlopen('http://div1.ceepur.org/REYDI_NocheDelEvento/data/GOBERNADOR_ISLA.xml').read()).getElementsByTagName('option')])) time.sleep(120) -
siloraptor revised this gist
Nov 8, 2012 . No changes.There are no files selected for viewing
-
siloraptor revised this gist
Nov 8, 2012 . No changes.There are no files selected for viewing
-
siloraptor revised this gist
Nov 8, 2012 . No changes.There are no files selected for viewing
-
siloraptor created this gist
Nov 8, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ import urllib2 from xml.dom.minidom import parseString import time print '\nGOVERNOR\nISLAND WIDE RESULTS\n', '-' * 19 while True: try: dom = parseString(urllib2.urlopen('http://div1.ceepur.org/REYDI_NocheDelEvento/data/GOBERNADOR_ISLA.xml').read()) date = dom.getElementsByTagName('date')[0] print '\n%s\n%s' % (date.childNodes[0].data, '=' * len(date.childNodes[0].data)) total_votes = int(sum([int(option.getElementsByTagName('votes')[0].childNodes[0].data) for option in dom.getElementsByTagName('option')])) print '\n\n'.join(map(lambda entry: '%(name)s (%(party)s) => %(votes)s (%(percent)s%%)' % entry, [{'party': option.getElementsByTagName('pe')[0].getElementsByTagName('es')[0].childNodes[0].data.title(), 'name': option.getElementsByTagName('name')[0].getElementsByTagName('es')[0].childNodes[0].data, 'votes': format(int(option.getElementsByTagName('votes')[0].childNodes[0].data), ',d'), 'percent': format(float(option.getElementsByTagName('votes')[0].childNodes[0].data) / total_votes * 100, '.3')} for option in dom.getElementsByTagName('option')])) print '\n%s\nTOTAL VOTES: %s\n%s\n' % ('=' * (len(format(total_votes, ',d')) + 13), format(total_votes, ',d'), '=' * (len(format(total_votes, ',d')) + 13)) time.sleep(120) except KeyboardInterrupt: exit(0)