urllib.urlopen

J

JabaPyth

Hello,
I'm trying to use the urllib module, but when i try urllib.urlopen, it
gives me a socket error:
Traceback (most recent call last):
File "<input>", line 1, in ?
File "C:\Python24\lib\urllib.py", line 77, in urlopen
return opener.open(url)
File "C:\Python24\lib\urllib.py", line 180, in open
return getattr(self, name)(url)
File "C:\Python24\lib\urllib.py", line 296, in open_http
h.endheaders()
File "C:\Python24\lib\httplib.py", line 794, in endheaders
self._send_output()
File "C:\Python24\lib\httplib.py", line 675, in _send_output
self.send(msg)
File "C:\Python24\lib\httplib.py", line 642, in send
self.connect()
File "C:\Python24\lib\httplib.py", line 610, in connect
socket.SOCK_STREAM):
IOError: [Errno socket error] (11001, 'getaddrinfo failed')

Any ideas on what i did wrong?
 
X

Xavier Morel

JabaPyth said:
Hello,
I'm trying to use the urllib module, but when i try urllib.urlopen, it
gives me a socket error:
Traceback (most recent call last):
File "<input>", line 1, in ?
File "C:\Python24\lib\urllib.py", line 77, in urlopen
return opener.open(url)
File "C:\Python24\lib\urllib.py", line 180, in open
return getattr(self, name)(url)
File "C:\Python24\lib\urllib.py", line 296, in open_http
h.endheaders()
File "C:\Python24\lib\httplib.py", line 794, in endheaders
self._send_output()
File "C:\Python24\lib\httplib.py", line 675, in _send_output
self.send(msg)
File "C:\Python24\lib\httplib.py", line 642, in send
self.connect()
File "C:\Python24\lib\httplib.py", line 610, in connect
socket.SOCK_STREAM):
IOError: [Errno socket error] (11001, 'getaddrinfo failed')

Any ideas on what i did wrong?
Works for me, do you have a proxy or some strange setup for accessing to
the web?

Try using the urllib2 module, too.
 
D

Dennis Lee Bieber

Hello,
I'm trying to use the urllib module, but when i try urllib.urlopen, it
gives me a socket error:
Your firewall might be blocking outgoing Python connections. (I get
error 7 if I set ZoneAlarm to block outgoing Python)

File "E:\Plone_2\Python\lib\httplib.py", line 535, in connect
socket.SOCK_STREAM):
IOError: [Errno socket error] (7, 'getaddrinfo failed')

Strange, the only errno 7 in my errno.h is E2BIG (and says "argument
list is too large)

11001 is WinSock for Host Not Found

(Now there is an interesting technical term:
#define ERROR_ARENA_TRASHED 7)
--
 
J

JabaPyth

I tried using urllib2 and this is what i got:Traceback (most recent call last):
File "<input>", line 1, in ?
File "C:\Python24\lib\urllib2.py", line 130, in urlopen
return _opener.open(url, data)
File "C:\Python24\lib\urllib2.py", line 358, in open
response = self._open(req, data)
File "C:\Python24\lib\urllib2.py", line 376, in _open
'_open', req)
File "C:\Python24\lib\urllib2.py", line 337, in _call_chain
result = func(*args)
File "C:\Python24\lib\urllib2.py", line 1021, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "C:\Python24\lib\urllib2.py", line 996, in do_open
raise URLError(err)
URLError: <urlopen error (11001, 'getaddrinfo failed')>
 
G

gene tani

Jay said:
Easy Fix...

import urllib
the_url = "http://www.google.com"
req = urllib.urlopen(the_url)

Does this work for you??

This does look like proxie /firewall issue, try it from an internet
cafe. Also depending on the site, you may have to set User-Agnet
and/or referer headers. And definitely respect robots.txt, throttle
back requests to seom finite (human-scale) volume and save them to your
hard drive (mistakes i've made)
 
J

JabaPyth

Thanks, guys.
I tried on a different computer, and it worked fine.I then found out
that my computer thyought i had a proxy server, and after i cleaned
that up, it worked.
Thanks again
 
T

Tom Anderson

(Now there is an interesting technical term:
#define ERROR_ARENA_TRASHED 7)

FreeBSD at one point had an EDOOFUS; Apple kvetched about this being
offensive, so it was changed to EDONTPANIC.

I shitteth thee not.

tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top