urllib.urlopen

Xavier Morel xavier.morel at masklinn.net
Sat Dec 17 17:46:13 EST 2005


JabaPyth wrote:
> Hello,
> I'm trying to use the urllib module, but when i try urllib.urlopen, it
> gives me a socket error:
> 
>     >>import urllib
>     >>print urllib.urlopen('http://www.google.com/').read()
>     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.



More information about the Python-list mailing list