在python中如何使用requests
包通过禁用证书验证的代理发出https请求(类似于curl中的--proxy-insecure
密钥(?我的代码:
import requests
requests.get('https://ip.quotaguard.com', proxies={'https': 'login:password@eu-west-shield-01.quotaguard.com:9294'}, verify=False)
也使用了verify=False
,但这与问题无关,因为这与curl中的-k
开关类似,它禁用了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
中没有,请推荐另一个库。
对于您的问题,以下链接中的第一句话是适用的:Requests是一个很棒的Python HTTP库。它允许您根据每个请求指定一个经过身份验证的代理,这样您就可以选择何时通过静态IP进行路由
https://devcenter.heroku.com/articles/quotaguardshield#https-代理python django
请求库仅使用HTTP代理,而不使用HTTPS代理。因此,在选项中列出HTTPS时,您使用的是HTTPS请求的HTTP代理,而不是HTTP(S(请求的HTTPS代理。因此,在您的情况下,QuotaGuard静态将起作用,而不是QuotaGuard-Shield(你的连接字符串看起来像你在盾牌上(
这可能有助于检查QuotaGuard静态和QuotaGuard-Shield之间的差异,因为它解释了为什么会出现这种情况:
https://www.quotaguard.com/why-is-quotaguard-shield-more-secure-than-quotaguard-static/
我希望这会有所帮助,请在这里告诉我,如果您在设置方面需要更多帮助,请通过支持联系我们。