免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5215 | 回复: 3
打印 上一主题 下一主题

大家Windows上的urllib.urlopen(...)正常吗? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-06-16 18:18 |只看该作者 |倒序浏览
我试了5台windows,其中4台xp,1台2003,都装的是ActivePython的最近的版本

其中3个执行不了下面的脚本,都报10061:connection refused错误,2台可以

网络肯定都是好的,太奇怪了

>>> import urllib
>>> re = urllib.urlopen('http://www.google.cn')

3台就卡在这等着报错了,不知道因为什么

有空的xd帮着试一下吧,谢谢了

论坛徽章:
0
2 [报告]
发表于 2008-06-16 20:30 |只看该作者
没有错误

你是用代理上网?有什么错误提示?

论坛徽章:
0
3 [报告]
发表于 2008-06-16 22:17 |只看该作者

回复 #2 asnama 的帖子

没有用代理,就是直连,晕菜了,我再想想

论坛徽章:
0
4 [报告]
发表于 2008-06-17 08:44 |只看该作者

回复 #2 asnama 的帖子

找到原因了,还是和proxy相关,个性的的urllib实现:

The urlopen() function works transparently with proxies which do not require
authentication. In a Unix or Windows
environment, set the http_proxy, ftp_proxy or gopher_proxy environment variables to a
URL that identifies the proxy server
before starting the Python interpreter. For example (the "%" is the command prompt):

% http_proxy="http://www.someproxy.com:3128"
% export http_proxy
% python
...

In a Windows environment, if no proxy environment variables are set, proxy settings
are obtained from the registry's
Internet Settings section.

简单说,windows下urllib默认会悄悄的把IE设定的proxy作为自己的proxy,

而我这段程序的目的正好是写一个proxy,所以只能死循环了

用urlopen得不到数据是因为它去找代理了,而设置的代理没有运行,且在本地,怪不得我抓包根本
抓不到向外发的包...
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP