urllib2.urlopen issue

David Wwy58 at yahoo.com
Wed Jun 24 19:50:50 CEST 2009


hello,

I have a url that is "http://query.directrdr.com/ptrack?
pid=225&v_url=http://
www.plentyoffish.com&keyword=flowers&feed=1&ip=12.2.2.2&said=$said".
If I open it on a browser, I can get its contents without any
problem.
However, if I use following code,


import urllib2


url = 'http://query.directrdr.com/ptrack?pid=225&v_url=http://
www.plentyoffish.com&keyword=flowers&feed=1&ip=12.2.2.2&said=$said'


xml = urllib2.urlopen(url).read()


then I get an exception of


 File "/usr/lib/python2.5/urllib2.py", line 1082, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error (-2, 'Name or service not known')>


I think this is caused by the embedded "v_url=..." in the url.
Anybody
knows how to fix this? By the way, this code works well if I change
the value of url to something like "www.yahoo.com" or
"www.google.com".


Thanks so much.





More information about the Python-list mailing list