Created
April 2, 2011 15:11
-
-
Save jbochi/899552 to your computer and use it in GitHub Desktop.
ZAP
This file contains 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 csv | |
import urllib | |
le_pagina = lambda pagina: eval(urllib.urlopen("http://webservices.apontador.com.br/zap/busca.ashx?busca=alugar&uf=RIO%20DE%20JANEIRO&cidade=RIO%20DE%20JANEIRO&page=" + str(pagina)).read())[0] | |
numero = lambda x: float(x.replace(',', '.')) | |
paginas = [le_pagina(i) for i in xrange(1, 8)] | |
f = open('imoveis.csv', 'w') | |
c = csv.writer(f) | |
c.writerow(['bairro', 'aluguel', 'area', 'latitude', 'longitude', 'zap_id']) | |
for pagina in paginas: | |
for linha in pagina: | |
bairro, area, aluguel, longitude, latitude, zap_id = linha | |
c.writerow([bairro, | |
aluguel, | |
area, | |
numero(latitude), | |
numero(longitude), | |
zap_id]) | |
f.close() | |
print 'feito' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment