473,703 Members | 5,073 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\li b\urllib.py", line 82, in urlopen
return opener.open(url )
File "C:\Python25\li b\urllib.py", line 190, in open
return getattr(self, name)(url)
File "C:\Python25\li b\urllib.py", line 325, in open_http
h.endheaders()
File "C:\Python25\li b\httplib.py", line 856, in endheaders
self._send_outp ut()
File "C:\Python25\li b\httplib.py", line 728, in _send_output
self.send(msg)
File "C:\Python25\li b\httplib.py", line 695, in send
self.connect()
File "C:\Python25\li b\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
4 9341
Hello,

Try to increase the time out : socket.settimeo ut(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\li b\urllib.py", line 82, in urlopen
return opener.open(url )
File "C:\Python25\li b\urllib.py", line 190, in open
return getattr(self, name)(url)
File "C:\Python25\li b\urllib.py", line 325, in open_http
h.endheaders()
File "C:\Python25\li b\httplib.py", line 856, in endheaders
self._send_outp ut()
File "C:\Python25\li b\httplib.py", line 728, in _send_output
self.send(msg)
File "C:\Python25\li b\httplib.py", line 695, in send
self.connect()
File "C:\Python25\li b\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.ProxyHa ndler({})
opener = urllib2.build_o pener(proxy_sup port)
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(tunn el_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,sel f._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\li b\urllib.py", line 82, in urlopen
return opener.open(url )
File "C:\Python25\li b\urllib.py", line 190, in open
return getattr(self, name)(url)
File "C:\Python25\li b\urllib.py", line 325, in open_http
h.endheaders()
File "C:\Python25\li b\httplib.py", line 856, in endheaders
self._send_outp ut()
File "C:\Python25\li b\httplib.py", line 728, in _send_output
self.send(msg)
File "C:\Python25\li b\httplib.py", line 695, in send
self.connect()
File "C:\Python25\li b\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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1381
by: C GIllespie | last post by:
Dear All, I'm having problems using the urllib module and was wondering if anyone could suggest a solution. The only thing I can thing of is that I'm using at university and my uni uses a compulsory proxy. I'm using the python 2.3.3 and have tried both windows and Linux environments. I've tried different urls as well. Here's the code and error message I get
2
2397
by: Andreas Dahl | last post by:
Hi, I use urllib to retrieve data via HTTP. Unfortunately my program crashes after a while (after some loops) because the connection timed out. raise socket.error, msg IOError: (60, 'Connection timed out') I am not so familiar with python, but is there a possibility to configure the 'waiting time'? Or how can I handle such an event? To skip
11
5050
by: Pater Maximus | last post by:
I am trying to implement the recipe listed at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/211886 However, I can not get to first base. When I try to run import urllib fo=urllib.urlopen("http://www.dictionary.com/") page = fo.read() I get:
3
2236
by: Chris Tavares | last post by:
Hi all. I'm currently tracking down a problem in a little script I have, and I was hoping that those more experienced than myself could weigh in. The script's job is to grab the status page off a DLink home router. This is a really simple job: I just use urllib.urlopen() to grab the status page. The router uses HTTP Basic authentication, so I've subclassed FancyURLOpener to supply the credentials. This all worked fine with an older...
11
3568
by: Johnny Lee | last post by:
Hi, I was using urllib to grab urls from web. here is the work flow of my program: 1. Get base url and max number of urls from user 2. Call filter to validate the base url 3. Read the source of the base url and grab all the urls from "href" property of "a" tag 4. Call filter to validate every url grabbed 5. Continue 3-4 until the number of url grabbed gets the limit
4
3589
by: william | last post by:
I've got a strange problem on windows (not very familiar with that OS). I can ping a host, but cannot get it via urllib (see here under). I can even telnet the host on port 80. Thus network seems good, but not for python ;-(. Does any windows specialist can guide me (a poor linux user) to get Network functionalitiies with python on windows ?
6
14530
by: JabaPyth | last post by:
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)
0
2447
by: Ali.Sabil | last post by:
hello all, I just maybe hit a bug in both urllib and urllib2, actually urllib doesn't support proxy authentication, and if you setup the http_proxy env var to http_proxy=http://user:passwd@host:port/ and https_proxy=$http_proxy i get a traceback : Traceback (most recent call last): File "test_urllib.py", line 2, in ? urllib.urlopen("https://sf.net/")
2
1880
by: Iain Dalton | last post by:
In Emacs, using run-python, import urllib urllib.urlopen('http://www.google.com/') results in this traceback: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.5/urllib.py", line 82, in urlopen
0
8760
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9254
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8967
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5923
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3125
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2070
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.