Skip to content

Instantly share code, notes, and snippets.

@jbochi
Created April 2, 2011 15:11
Show Gist options
  • Save jbochi/899552 to your computer and use it in GitHub Desktop.
Save jbochi/899552 to your computer and use it in GitHub Desktop.
ZAP
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