views:

336

answers:

2

I'm getting an error when ever I try to pull down a web page with urllib.urlopen. I've disabled windows firewall and my AV so its not that. I can access the pages in my browser. I even reinstalled python to rule out it being a broken urllib. Any help would be greatly appreciated.

>>> import urllib
>>> h = urllib.urlopen("http://www.google.com").read()

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    h = urllib.urlopen("http://www.google.com").read()
  File "C:\Python26\lib\urllib.py", line 86, in urlopen
    return opener.open(url)
  File "C:\Python26\lib\urllib.py", line 205, in open
    return getattr(self, name)(url)
  File "C:\Python26\lib\urllib.py", line 344, in open_http
    h.endheaders()
  File "C:\Python26\lib\httplib.py", line 904, in endheaders
    self._send_output()
  File "C:\Python26\lib\httplib.py", line 776, in _send_output
    self.send(msg)
  File "C:\Python26\lib\httplib.py", line 735, in send
    self.connect()
  File "C:\Python26\lib\httplib.py", line 716, in connect
    self.timeout)
  File "C:\Python26\lib\socket.py", line 514, in create_connection
    raise error, msg
IOError: [Errno socket error] [Errno 10061] No connection could be made because the target machine actively refused it
>>> 
A: 

urllib is working just fine.

Try using ethereal (or some similar network sniffer) on your box to determine if the denial coming from your machine or a machine beyond.

MikeyB
It can't be a machine beyond, my browser can access the websites I'm trying. And its happening with every single website I try so its not some useragent problem or anything similar.
mudder
+2  A: 

this could be the case:

Just found the problem I had set a proxy through internet options, that proxy went offline, and so did my python shell.

mykhal
Yup, that was it. Apparently Idle uses the proxy settings from internet options. Thanks a lot Mykhal
mudder