What am I doing wrong with urllib.urlopen() ?

Jose Rivera jriveramerla at yahoo.com
Tue Mar 19 19:17:15 EST 2002


Hi...

Thanks in advance for any help...

I want to retrieve data from the web for historic research 
about real state prices, fetching the info from a newspaper page, 
for personal use, loading this to MySQL DataBase for later study on
trends, but I don't want to be doing this procedure manually every
day.

But this routine just gives me an error, please try it 
and see whats wrong?, I have not found what am I missing.

When I try the address genereated by the code directly on the
iExplorer.EXE, it works... but not on Python...

This is the routine:
--------------------
import os
import urllib

params={}
params["pagina"] = 1
params["Presentacion"] = "Tabla"
params["Tipo"] = "CASAS"
params["Order"] = "Order By Fecha Desc"
params["id_inmueble"] = "3"
params["zona"] = "0"
params["COLONIA"] = "0"
params["RECAMARAS"] = "0"
params["BANOS"] = "0"
params["dia"] = 	''
params["PLANTAS"] = "0"
params["Constr_i"] = "-1"
params["constr_f"] = "-1"
params["Terreno_i"] = "-1"
params["Terreno_f"] = "-1"
params["Precio_i"] = "-1"
params["Precio_f"] = "-1"
params["fotos"] = "0"

# This is the address calculated
#http://avisos.elnorte.com/casa_venta_result.asp?fotos=0&Order=order+by+colonia&Precio_i=-1&Presentacion=Tabla&Precio_f=-1&PLANTAS=0&pagina=1&id_inmueble=3&dia=&RECAMARAS=0&constr_f=-1&COLONIA=0&BANOS=0&Tipo=CASAS&Constr_i=-1&Terreno_i=-1&Terreno_f=-1&zona=0

pms=urllib.urlencode(params)
direccion="HTTP://AVISOS.ELNORTE.COM/casa_venta_result.asp?%s"%pms
#print direccion
f=urllib.urlopen(direccion)

ff=open('xc.htm','w')
ff.write('<strong>'+direccion+'<\br>')
ff.write(f.read())
ff.close

os.system('start xc.htm')



More information about the Python-list mailing list