使用代理IP访问网站时出现的问题
使用代理IP代码大概如下:
proxy = {
‘http’:‘http://’ + proxy_host,
‘https’:‘https://’ + proxy_host
}
r = requests.get(url, proxies = proxy)
错误一:
requests.exceptions.ProxyError: HTTPSConnectionPool(host=‘stock2.finance.sina.com.cn’, port=443): Max retries exceeded with url: /futures/api/jsonp.php/=/InnerFuturesNewService.getFewMinLine?symbol=V2401&type=1 (Caused by ProxyError(‘Unable to connect to proxy. Your proxy appears to only use HTTP and not HTTPS, try changing your proxy URL to be HTTP. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#https-proxy-error-http-proxy’, SSLError(SSLError(1, ‘[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1122)’))))
原因分析:
通过错误提示只使用HTTP而不使用HTTPS,因此将代理IP里面的HTTPS直接删掉即可。文章来源:https://www.toymoban.com/news/detail-852474.html
修改如下:
proxy = {
‘http’:‘http://’ + proxy_host
}文章来源地址https://www.toymoban.com/news/detail-852474.html
到了这里,关于Unable to connect to proxy. Your proxy appears to only use HTTP and not HTTPS, try changing your pro的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!