requests.exceptions.ProxyError: HTTPSConnectionPool(host=‘httpbin.org‘, port=443)

报错代码

import requests
proxy = requests.get('http://api.xdaili.cn/xdaili-api//greatRecharge/getGreatIp?spiderId=1bfff22283ec488bacc302a679a0a651&orderno=YZ20224181764ow5pXx&returnType=1&count=1').text
proxy = proxy.strip() #这一步很重要,因为要清除换行符等多余的字符
#proxies = {'http':'http://' + proxy,'https://' + proxy}
proxies = {"http": "http://"+proxy, "https": "https://"+proxy}
url = 'https://httpbin.org/get'
res = requests.get(url,proxies=proxies).text
print(res)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='httpbin.org', port=443): Max retries exceeded with url: /get (Caused by ProxyError('Your proxy appears to only use HTTP and not HTTPS, try changing your proxy URL to be HTTP. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#https-proxy-error-http-proxy', SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1129)'))))

  • 注意其中的这句话Your proxy appears to only use HTTP and not HTTPS, try changing your proxy URL to be HTTP.

修改问题代码行(url)

  • 将第7行代码的url改为如下:
url = 'http://httpbin.org/get'
{
  "args": {}, 
  "headers": {
    "Accept": "*/*", 
    "Accept-Encoding": "gzip, deflate", 
    "Cache-Control": "max-age=259200", 
    "Host": "httpbin.org", 
    "User-Agent": "python-requests/2.27.1", 
    "X-Amzn-Trace-Id": "Root=1-625e5577-753ec71749f324a65d9af91d"
  }, 
  "origin": "120.42.132.40", 
  "url": "http://httpbin.org/get"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值