确定代理类型
我有以下代码通过代理下载 URL:
proxy_handler = urllib2.ProxyHandler({'http': p})
opener = urllib2.build_opener(proxy_handler)
urllib2.install_opener(opener)
req = urllib2.Request(url)
sock = urllib2.urlopen(req)
How can I use Python to certain the type of proxy it is (transparent, anonymous, etc)? 一种解决方案是使用外部服务器,但我想尽可能避免这种依赖。
I have the following code to download a URL through a proxy:
proxy_handler = urllib2.ProxyHandler({'http': p})
opener = urllib2.build_opener(proxy_handler)
urllib2.install_opener(opener)
req = urllib2.Request(url)
sock = urllib2.urlopen(req)
How can I use Python to determine the type of proxy it is (transparent, anonymous, etc)?
One solution would be to use an external server, but I want to avoid that kind of dependency if possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须拥有某种类型的服务器。
您可以希望做的最佳选择是托管您自己的网络服务器并打印标头以查看它是否泄漏任何变量。
You must have a server of some sort.
The best option you can hope of doing is to host your own web server and print the headers to see if it is leaking any variables.
您的意思是检索当前的代理配置吗?
您可以使用 urllib.getproxies:
注意:我无法找到有关 urllib.getproxies 的任何文档。 我正在使用 Python 2.5,它可以正常工作。
Do you mean retrieving the current proxy configuration?
You can with urllib.getproxies:
Note: I was not able to find any documentation about urllib.getproxies. I am using Python 2.5, and it just works.