-
-
Save xstpl/d50fd6afa0a0f4d0b909 to your computer and use it in GitHub Desktop.
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 characters
import urllib2 | |
import json | |
UF = ['AC','AL','AM','AP','BA','CE','DF','ES','GO','MA','MG','MS','MT','PA','PB','PE','PI','PR','RJ','RN','RO','RR','RS','SC','SE','SP','TO'] | |
#UF = ['AC','AL','AM','AP','BA','CE'] | |
for estado in UF: | |
#print estado | |
urlCidade = 'https://ww18.itau.com.br/wsinvestnet/Corban.asmx/MontarCombosCorbanCidade?estado=' + estado + '&servico=3&segmento=8&callback=_jqjsp&_1412367567213=' | |
resp = urllib2.urlopen(urlCidade).read() | |
resp = resp.replace('_jqjsp({"d":"{\\"?xml\\":{\\"@version\\":\\"1.0\\",\\"@encoding\\":\\"utf-8\\"},\\"root\\":{\\"listaCidade\\":{\\"row\\":','[') | |
resp = resp.replace('}}}"});',']') | |
resp = resp.replace('\\','') | |
resp = resp.replace('[[{"','[{"') | |
resp = resp.replace('"}]]','"}]') | |
for mun in json.loads(resp.decode('utf-8')): | |
#print estado + " - " + mun['DescricaoMunicipio'].strip() + " - " + mun['CodigoMunicipio'] | |
codMun = mun['CodigoMunicipio'] | |
municip = mun['DescricaoMunicipio'].strip() | |
urlCidade = 'https://ww18.itau.com.br/wsinvestnet/Corban.asmx/MontarCombosCorbanBairro?codCidade=' + codMun + '&estado=' + estado + '&servico=3&segmento=8&callback=_jqjsp&_1412624740327=' | |
respA = urllib2.urlopen(urlCidade).read() | |
respA = respA.replace('_jqjsp({"d":"{\\"?xml\\":{\\"@version\\":\\"1.0\\",\\"@encoding\\":\\"utf-8\\"},\\"root\\":{\\"listaBairro\\":{\\"row\\":','[') | |
respA = respA.replace('}}}"});',']') | |
respA = respA.replace('\\','') | |
respA = respA.replace('[[{"','[{"') | |
respA = respA.replace('"}]]','"}]') | |
#print respA | |
try: | |
if 'null' in respA: | |
urlCorrespondente = 'https://ww18.itau.com.br/wsinvestnet/Corban.asmx/BuscarCorrespondenteBancario?cidade=' + codMun + '&estado=' + estado + '&servico=3&segmento=8&bairro=Bairro&nomeFantasiaCorrespondente=&callback=_jqjsp&_1412625558140=' | |
respB = urllib2.urlopen(urlCorrespondente).read() | |
respB = respB.replace('_jqjsp({"d":"{\\"?xml\\":{\\"@version\\":\\"1.0\\",\\"@encoding\\":\\"utf-8\\"},\\"root\\":{\\"listaCorrespondente\\":{\\"row\\":','[') | |
respB = respB.replace('}}}"});',']') | |
respB = respB.replace('\\','') | |
respB = respB.replace('[[{"','[{"') | |
respB = respB.replace('"}]]','"}]') | |
respB = respB.replace('{"@xml:space":"preserve","#significant-whitespace":" "}','" "') | |
#print respB | |
for correspondente in json.loads(respB.decode('utf-8')): | |
print estado + " - " + municip + " - " + codMun + " - " + bairro['DescricaoBairro'].strip() + " - " + bairro['CodigoBairro'] + " - " + correspondente['NomeFantasiaCorrespondente'].strip() + " - " + correspondente['CnpjCorrespondente'] + " - " + correspondente['DescricaoEnderecoCorrespondente'].strip() | |
else: | |
for bairro in json.loads(respA.decode('utf-8')): | |
codBairro = bairro['CodigoBairro'] | |
urlCorrespondente = 'https://ww18.itau.com.br/wsinvestnet/Corban.asmx/BuscarCorrespondenteBancario?cidade=' + codMun + '&estado=' + estado + '&servico=3&segmento=8&bairro=' + codBairro + '&nomeFantasiaCorrespondente=&callback=_jqjsp&_1412625558140=' | |
respB = urllib2.urlopen(urlCorrespondente).read() | |
respB = respB.replace('_jqjsp({"d":"{\\"?xml\\":{\\"@version\\":\\"1.0\\",\\"@encoding\\":\\"utf-8\\"},\\"root\\":{\\"listaCorrespondente\\":{\\"row\\":','[') | |
respB = respB.replace('}}}"});',']') | |
respB = respB.replace('\\','') | |
respB = respB.replace('[[{"','[{"') | |
respB = respB.replace('"}]]','"}]') | |
respB = respB.replace('{"@xml:space":"preserve","#significant-whitespace":" "}','" "') | |
respB = respB.replace(', ',' ') | |
# print respB | |
for correspondente in json.loads(respB.decode('utf-8')): | |
print estado + " - " + municip + " - " + codMun + " - " + bairro['DescricaoBairro'].strip() + " - " + bairro['CodigoBairro'] + " - " + correspondente['NomeFantasiaCorrespondente'].strip() + " - " + correspondente['CnpjCorrespondente'] + " - " + correspondente['DescricaoEnderecoCorrespondente'].strip() | |
except Exception: | |
print "_______________________________________________________________________________________________________________" | |
pass | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment