实际情况是我需要用谷歌的 api,就是 googleapiclient 这个包,那么还得代理下才能用,看了源码需要传一个设置好代理的 http 实例过去,但是死活就不行
测试了下
import httplib2
http = httplib2.Http(proxy_info=httplib2.ProxyInfo( httplib2.socks.PROXY_TYPE_SOCKS5, '127.0.0.1', 1080),timeout=10)
resp, content = http.request('https://www.google.com', 'GET')
print(resp)
根本没走代理,谷歌无果,心灰意冷,翻翻源码,才发现
class HTTPSConnectionWithTimeout( http.client.HTTPSConnection):
"""
This class allows communication via SSL.
All timeouts are in seconds. If None is passed for timeout then
Python's default timeout for sockets will be used. See for example
the docs of socket.setdefaulttimeout():
http://docs.python.org/library/socket.html#socket.setdefaulttimeout
"""
def __init__(self, host, port=None, key_file=None, cert_file=None,
timeout=None, proxy_info=None,
ca_certs=None, disable_ssl_certificate_validation=False):
# TODO: implement proxy_info
self.proxy_info = proxy_info
context = None
TODO: implement proxy_info,凉了?
py 新手,很久以前学了下然后语法啥都忘光了,刚刚捡起来,各位看看我说的对不对,还有没有办法解决我的实际情况
1
hcymk2 2018-01-09 14:58:36 +08:00
proxychains
|
2
prolic 2018-01-09 15:02:36 +08:00
|
3
rikka OP @prolic #2 我打开过这个 issue,二楼方法测试了下就报错,然后没完全耐心再去看什么,刚刚再测试,第一次报证书错误,第二次就 ok 了
|
4
rikka OP @prolic #2 哦,不对是访问 https://www.google.com 报证书错误,但是谷歌的 api 没问题
|