Commit a891144f1ac7d3c3ee8105169f954bf65aa1c02f

Wrong case is wrong
failburn.py
(12 / 18)
  
99
1010# fake user-agent
1111headers = {'User-Agent': 'Mozilla/5.0 (X11; U; Linux i686; en-US; ' \
12 'rv:1.9.0.2) Gecko/2008092313 Ubuntu/8.04 (hardy) Firefox/3.1.6'}
12 'rv:1.9.0.2) Gecko/2008092313 Ubuntu/8.04 (hardy) Firefox/3.1.6'}
1313
1414#sources = ['Inidoneas', 'Suspensas']
1515sources = ['Testing']
1616
17def _donations(cnpj, name):
18 """Search for donations from the CNPJ/Name"""
19
2017for source in sources:
2118 print source + ':'
2219 content = csv.reader(open(source + '.csv'), delimiter=';')
2320
24 # little dirty trick to skip the first row (first next() gets the row,
25 # second moves to the second row, so the for starts there.)
21 # The data have two headers
2622 content.next()
2723 content.next()
2824
29 for row in content: # skip the headers
25 for row in content:
3026 print row[0], row[1].decode('iso-8859-1'),
3127
3228 # remove ".", "/" and "-". Do not translate any other characters.
3434 continue
3535
3636 form = {
37 'sgUe': '',
38 'acao': 'Resumo',
37 'acao': 'resumo',
38 'cdCpfCnpjDoador': cnpj_clean,
39 'cdEspRecurso': '-1', # any
40 'dsCargo': '',
41 'municipio': '',
42 'nmCandidato': '',
3943 'nomeFornecDoador': 'Doador',
44 'nrCand': '',
4045 'rdTipo': 'receita',
41 'nmDoador': row[1],
42 'cdCpfCnpjDoador': cnpj_clean,
43 'cdEspRecurso': '-1' # any
46 'sgPartido': '',
47 'sgUe': '',
4448 }
4549
4650 request = urllib2.Request(url='http://www4.tse.gov.br/' \
5252 'consultaReceitaDespesaCandidatoServlet.do')
5353
5454 for key in headers:
55 #print 'Header', key, '=', headers[key]
5655 request.add_header(key, headers[key])
5756
5857 body = urllib.urlencode(form)
59 #print body
60
6158 request.add_data(body)
6259
6360 response = urllib2.urlopen(request)
6666 output.close()
6767
6868 print ' --> done'
69
70 time.sleep(30) # So we don't "burn" the server.
71
7269
7370 print