Skip to content

Instantly share code, notes, and snippets.

@elinaldosoft
Created October 8, 2014 00:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elinaldosoft/a747ba3c9f66b53c7373 to your computer and use it in GitHub Desktop.
Save elinaldosoft/a747ba3c9f66b53c7373 to your computer and use it in GitHub Desktop.
Eleicoes
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2,json
def main():
resp = json.loads(urllib2.urlopen("http://divulga.tse.jus.br/2014/divulgacao/oficial/143/dadosdivweb/br/br-0001-e001431-w.js").read())
for cad in resp['cand']:
if (float(cad['v']) / float(resp['vv'])) * 100 > 10:
print "Candidado: %s: votos: %s percentual: %.2f%% de %.1f%% dos votos apurados" % (cad['nm'], cad['v'], (float(cad['v']) / float(resp['vv'])) * 100, (float(resp['ea']) / float(resp['e']) * 100))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment