Thread View: pl.comp.lang.python
2 messages
2 total messages
Started by David
Wed, 24 Jun 2009 17:45
urllib2 open problem
Author: David
Date: Wed, 24 Jun 2009 17:45
Date: Wed, 24 Jun 2009 17:45
27 lines
1931 bytes
1931 bytes
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.
Re: urllib2 open problem
Author: David
Date: Wed, 24 Jun 2009 17:48
Date: Wed, 24 Jun 2009 17:48
29 lines
2370 bytes
2370 bytes
On Jun 24, 10:45 am, David <ww...@yahoo.com> wrote: > 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. Seems to me that I have posted to a wrong place. Can the admin delete it? Sorry for it.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads