python urllib 的问题

发布于 2024-09-01 20:13:20 字数 1185 浏览 0 评论 0原文

当我尝试使用 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
>>> 

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

温柔女人霸气范 2024-09-08 20:13:21

urllib 工作得很好。

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

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.

南冥有猫 2024-09-08 20:13:20

可能是这种情况

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文