Reputation: 595
I have a trouble of connecting to a website using httplib2. My computer is behind a firewall and, as https://code.google.com/p/httplib2/wiki/Examples suggests, I did as follows:
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. Can anybody help me?
Upvotes: 4
Views: 12628
Reputation: 481
It depends on your proxy server, if you use socket5(Shadowsock) you can use this
http = httplib2.Http(proxy_info=httplib2.ProxyInfo(
httplib2.socks.PROXY_TYPE_SOCKS5, '127.0.0.1', 1080))
Upvotes: 0
Reputation: 71
You can try using "PROXY_TYPE_HTTP_NO_TUNNEL" if your server requires no tunneling
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
Upvotes: 7