Max retries exceeded with url错误

Posted classid

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Max retries exceeded with url错误相关的知识,希望对你有一定的参考价值。

进行requests库学习的时候,报Max retries exceeded with url错误,网上查询说是,用下面这个解决方法没用,后来关闭了fiddler后发现就可以了,可能fiddler开的连接数太多了

http连接太多没有关闭导致的

解决办法:

1、增加重试连接次数

  requests.adapters.DEFAULT_RETRIES = 5
  • 1

2、关闭多余的连接

requests使用了urllib3库,默认的http connection是keep-alive的,requests设置False关闭。

操作方法

s = requests.session()
  s.keep_alive = False
import requests,json,unittest
def send_req(url,method,data=None):
if method==‘GET‘:
requests.adapters.DEFAULT_RETRIES = 5
s = requests.session()
s.keep_alive = False
res=requests.get(url=url).json()
return json.dumps(res,indent=2)
else:
res=requests.post(url=url,data=data)
return res.json()
url=r‘https://www.baidu.com/home/xman/data/tipspluslist?indextype=manht&_req_seqid=0xe84d39f7000079b2&asyn=1&t=1535105478702&sid=26524_1442_21097_26921_22159‘
res=send_req(url,‘GET‘)












以上是关于Max retries exceeded with url错误的主要内容,如果未能解决你的问题,请参考以下文章

requests.exceptions.SSLError……Max retries exceeded with url错误求助!!!

HTTPConnectionPool(host='xx.xx.xx.xx', port=xx): Max retries exceeded with url:(Caused by Co

Python requests返回`Max retries exceeded`错误

关于python3.6上传文件时报错:HTTPSConnectionPool(host='httpbin.org', port=443): Max retries exceeded w

ERROR 0199: Security password retry count exceeded.

ERROR 0199: Security password retry count exceeded.