如何在 python 中使用requests
包通过禁用证书验证的代理发出 https 请求(类似于--proxy-insecure
curl 中的密钥)?我的代码:
import requests
requests.get('https://ip.quotaguard.com', proxies={'https': 'login:password@eu-west-shield-01.quotaguard.com:9294'}, verify=False)
verify=False
也被使用,但这与问题无关,因为这是-k
curl 中的开关的类似物,它禁用验证ip.quotaguard.com
,而代理eu-west-shield-01.quotaguard.com:9294
则不会。
代码抛出错误ValueError: check_hostname needs a SSL context with either CERT_OPTIONAL or CERT_REQUIRED
。
通过curl,请求成功返回结果,这里是请求本身:
curl -x "https://login:password@eu-west-shield-01.quotaguard.com:9294" -L "https://ip.quotaguard.com" --proxy-insecure -k
如果有这种可能,但不在requests
,请推荐另一个库。