467,074 Members | 918 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,074 developers. It's quick & easy.

urllib.urlopen: Errno socket error

Hi,

I'm just trying to read from a webpage with urllib but I'm getting
IOErrors. This is my code:

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

and this is the error:

Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
sock = urllib.urlopen("http://www.google.com/")
File "C:\Python25\lib\urllib.py", line 82, in urlopen
return opener.open(url)
File "C:\Python25\lib\urllib.py", line 190, in open
return getattr(self, name)(url)
File "C:\Python25\lib\urllib.py", line 325, in open_http
h.endheaders()
File "C:\Python25\lib\httplib.py", line 856, in endheaders
self._send_output()
File "C:\Python25\lib\httplib.py", line 728, in _send_output
self.send(msg)
File "C:\Python25\lib\httplib.py", line 695, in send
self.connect()
File "C:\Python25\lib\httplib.py", line 679, in connect
raise socket.error, msg
IOError: [Errno socket error] (10060, 'Operation timed out')

I'm behind my company's firewall. Would that cause a problem? If it
does, How do I get around it?

Oct 16 '06 #1
  • viewed: 8941
Share:
4 Replies
Hello,

Try to increase the time out : socket.settimeout(n)
and catch the timeout error when it occurs

Regards

kg******@gmail.com a écrit :
Hi,

I'm just trying to read from a webpage with urllib but I'm getting
IOErrors. This is my code:

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

and this is the error:

Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
sock = urllib.urlopen("http://www.google.com/")
File "C:\Python25\lib\urllib.py", line 82, in urlopen
return opener.open(url)
File "C:\Python25\lib\urllib.py", line 190, in open
return getattr(self, name)(url)
File "C:\Python25\lib\urllib.py", line 325, in open_http
h.endheaders()
File "C:\Python25\lib\httplib.py", line 856, in endheaders
self._send_output()
File "C:\Python25\lib\httplib.py", line 728, in _send_output
self.send(msg)
File "C:\Python25\lib\httplib.py", line 695, in send
self.connect()
File "C:\Python25\lib\httplib.py", line 679, in connect
raise socket.error, msg
IOError: [Errno socket error] (10060, 'Operation timed out')

I'm behind my company's firewall. Would that cause a problem? If it
does, How do I get around it?
Oct 16 '06 #2
Hi Salvatore,

Even if I catch the exceptions in a loop it goes on forever.

- ken

Oct 16 '06 #3
Dennis,

I tried a ProxyHandler with the following code ...

proxy_support = urllib2.ProxyHandler({})
opener = urllib2.build_opener(proxy_support)
urllib2.install_opener(opener)

.... but it's giving me the same result.

Then I tried to tunnel using code from ...

http://aspn.activestate.com/ASPN/Coo.../Recipe/213238

.... but it too gave me an error ...

Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
tunnel.run(tunnel_this)
File "C:/Python25/My Python/PyTunnel.py", line 124, in run
Threads.append( thread_it(tid=0,proxy=self.get_proxy(),\
File "C:/Python25/My Python/PyTunnel.py", line 81, in get_proxy
proxy.connect((self._phost,self._pport))
File "<string>", line 1, in connect
gaierror: (11001, 'getaddrinfo failed')

Oct 17 '06 #4

kg******@gmail.com a écrit :
Hi,

I'm just trying to read from a webpage with urllib but I'm getting
IOErrors. This is my code:

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

and this is the error:

Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
sock = urllib.urlopen("http://www.google.com/")
File "C:\Python25\lib\urllib.py", line 82, in urlopen
return opener.open(url)
File "C:\Python25\lib\urllib.py", line 190, in open
return getattr(self, name)(url)
File "C:\Python25\lib\urllib.py", line 325, in open_http
h.endheaders()
File "C:\Python25\lib\httplib.py", line 856, in endheaders
self._send_output()
File "C:\Python25\lib\httplib.py", line 728, in _send_output
self.send(msg)
File "C:\Python25\lib\httplib.py", line 695, in send
self.connect()
File "C:\Python25\lib\httplib.py", line 679, in connect
raise socket.error, msg
IOError: [Errno socket error] (10060, 'Operation timed out')

I'm behind my company's firewall. Would that cause a problem? If it
does, How do I get around it?

See the documentation for urllib.urlopen:

"""
In a Windows environment, if no proxy environment variables are set,
proxy settings are obtained from the registry's Internet Settings
section.
"""
Remove Proxy configuration under IE and try again
(don't use Ie anymore ;0)

Nov 10 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by C GIllespie | last post: by
2 posts views Thread by Andreas Dahl | last post: by
11 posts views Thread by Pater Maximus | last post: by
3 posts views Thread by Chris Tavares | last post: by
11 posts views Thread by Johnny Lee | last post: by
4 posts views Thread by william@opensource4you.com | last post: by
6 posts views Thread by JabaPyth | last post: by
reply views Thread by Ali.Sabil@gmail.com | last post: by
2 posts views Thread by Iain Dalton | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.