Commit f530d881044e371cf2dcdfe5b8a95d669bb01cab
- Diff rendering mode:
- inline
- side by side
cnpjs.zip
(5348 / 0)
Binary files differ
failburn.py
(8 / 3)
|   | |||
| 5 | 5 | import urllib | |
| 6 | 6 | import urllib2 | |
| 7 | 7 | import time | |
| 8 | import os | ||
| 8 | 9 | ||
| 9 | 10 | # fake user-agent | |
| 10 | 11 | headers = {'User-Agent': 'Mozilla/5.0 (X11; U; Linux i686; en-US; ' \ | |
| … | … | ||
| 30 | 30 | ||
| 31 | 31 | # remove ".", "/" and "-". Do not translate any other characters. | |
| 32 | 32 | cnpj_clean = row[0].translate(None, './-') | |
| 33 | result_filename = cnpj_clean + '.result' | ||
| 33 | 34 | ||
| 35 | if os.access(result_filename, os.F_OK): | ||
| 36 | print ' --> skipping' | ||
| 37 | continue | ||
| 38 | |||
| 34 | 39 | form = { | |
| 35 | 40 | 'sgUe': '', | |
| 36 | 41 | 'acao': 'Resumo', | |
| … | … | ||
| 63 | 63 | data = response.read() | |
| 64 | 64 | response.close() | |
| 65 | 65 | ||
| 66 | name = cnpj_clean + '.result' | ||
| 67 | output = file(name, 'w') | ||
| 66 | output = file(result_filename, 'w') | ||
| 68 | 67 | output.write(data) | |
| 69 | 68 | output.close() | |
| 70 | 69 | ||
| 71 | 70 | print ' --> done' | |
| 72 | 71 | ||
| 73 | time.sleep(5) # So we don't "burn" the server. | ||
| 72 | time.sleep(30) # So we don't "burn" the server. | ||
| 74 | 73 | ||
| 75 | 74 | ||
| 76 | 75 |

