关于 Python urllib3 ProxyManager 中SSL安全验证的问题
最近自学python 遇到很多问题,耽误了很多时间,通过自己网上找各种答案终于解决了,希望对你们有帮助。`
localurl = 'http://127.0.0.1:5000/random'
ip_proxy = requests.get(url=localurl, headers=headers)
proxies = ip_proxy.text
proxies1 = 'http://%s' % (proxies)
上面这部分是我搭建的IP池中请求IP数据
proxy =urllib3.ProxyManager(proxies1,cert_reqs='CERT_REQUIRED', ca_certs=certifi.where())
r =proxy.request('post', url + "/post", fields=fields, headers=header)`**
上面这部分是正确的请求方式,能够正确返回值,记得import urllib3。之前报错`raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘feedback.aliexpress.com’, port=443): Max retries exceeded with url: /display/productEvaluation.htm (Caused by ProxyError(‘Cannot connect to proxy.’, NewConnectionError(’<urllib3.connection.VerifiedHTTPSConnection object at 0x000001BC4C4BA6A0>: Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。’)))
Error([(‘SSL routines’, ‘tls_process_server_certificate’, ‘certificate verify failed’)])
参照以下文档:
https://www.jianshu.com/p/df9b883fecae
https://blog.csdn.net/taiyangdao/article/details/72825735
https://blog.csdn.net/fq_zhang/article/details/50906213
`