python urllib的问题

时间:2010-05-19 19:57:59

标签: python urllib

我尝试使用urllib.urlopen下载网页时遇到错误。我已禁用Windows防火墙和我的AV,所以它不是那样的。我可以在浏览器中访问这些页面。我甚至重新安装了python以排除它是一个破坏的urllib。任何帮助将不胜感激。

>>> 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
>>> 

2 个答案:

答案 0 :(得分:5)

this could be the case

  

刚刚发现我设置的问题   代理通过互联网选​​项,那   代理离线了,我的也是   python shell。

答案 1 :(得分:0)

urllib工作得很好。

尝试在您的盒子上使用ethereal(或类似的网络嗅探器)来确定拒绝是来自您的机器还是来自机器。