[英]setting proxy on httplib2
I have a trouble of connecting to a website using httplib2. 我无法使用httplib2连接到网站。 My computer is behind a firewall and, as https://code.google.com/p/httplib2/wiki/Examples suggests, I did as follows: 我的计算机位于防火墙后面,如https://code.google.com/p/httplib2/wiki/Examples所示,我做了如下操作:
import httplib2
from httplib2 import socks
http = httplib2.Http(proxy_info = httplib2.ProxyInfo(socks.PROXY_TYPE_HTTP, <proxy host address>, 8080, proxy_user = <proxy user id>, proxy_pass = <proxy password>))
resp, content = http.request("http://google.com", "GET")
But, I am still getting 但是,我还在
httplib2.ServerNotFoundError: Unable to find the server at google.com
My computer works fine with urllib2. 我的电脑可以正常使用urllib2。 Can anybody help me? 有谁能够帮我?
You can try using "PROXY_TYPE_HTTP_NO_TUNNEL" if your server requires no tunneling 如果您的服务器不需要隧道,您可以尝试使用“PROXY_TYPE_HTTP_NO_TUNNEL”
import httplib2
http = httplib2.Http(proxy_info = httplib2.ProxyInfo(httplib2.socks.PROXY_TYPE_HTTP_NO_TUNNEL, 'proxy.example.com', 8080, proxy_user = 'username', proxy_pass = 'password') )
resp, content = http.request("http://google.com", "GET")
It was a known bug that was fixed due to an issue #38 由于问题#38 ,这是一个已知的错误
这取决于您的代理服务器,如果您使用socket5(Shadowsock),您可以使用它
http = httplib2.Http(proxy_info=httplib2.ProxyInfo( httplib2.socks.PROXY_TYPE_SOCKS5, '127.0.0.1', 1080))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.