当前位置: 移动技术网 > IT编程>脚本编程>Python > requests 处理异常错误 requests.exceptions.ConnectionError HTTPSConnectionPool [Errno 10060]

requests 处理异常错误 requests.exceptions.ConnectionError HTTPSConnectionPool [Errno 10060]

2019年03月21日  | 移动技术网IT编程  | 我要评论

d318,炉温曲线测试仪,豆乳饱倍

  使用python requests模块调用vmallarg.vmall.com接口api时报如下错误:
requests.exceptions.connectionerror: httpsconnectionpool(host='vmallrag.vmall.com', port=443): max retries exceeded with url: .... (caused by new connectionerror('ect at 0x01c3da10>: failed to establish a new connection: [errno 10060] ',))
 
测试场景:
  在postman中调用时可以成功返回,在浏览器中也可以成功访问该网址。
 
然而在dos下telnet连接失败:

 

这是为什么呢?原来在公司内网设置了浏览器代理服务器,想访问外部网址必须经过代理服务器才能访问,公司代理服务器地址:xx.aa.com 端口:8080(这个代理在ie设置局域网中可以看到)

 

所以在requests中设置对应的代理就能连接正常了,代理设置如下:

  https的请求代理:proxy = {"https":"xx.aa.com:8080"},http的请求代理: proxy = {"http":"xx.aa.com:8080"},或者http/https的一并设置:proxy={"https":"xx.aa.com:8080","http":"xx.aa.com:8080"}

然后在requests的get、post方法中指定如下:
  requests.get(url, proxies=proxy)
  requests.post(url, proxies=proxy)

 

 

 

 

 

 
 
 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网