Python Max retries exceeded with url错误
进行requests库学习的时候,报Max retries exceeded with url错误,网上查询说是,用下面这个解决方法没用,后来关闭了fiddler后发现就可以了,可能fiddler开的连接数太多了,http连接太多没有关闭导致的。
解决办法:
1、增加重试连接次数
requests.adapters.DEFAULT_RETRIES = 5
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 = 5s = requests.session()s.keep_alive = Falseres=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')
参考:https://www.cnblogs.com/classid/p/9532790.html
Python Max retries exceeded with url错误相关推荐
- 【爬虫 | Python】解决‘Requests Max Retries Exceeded With Url‘报错的问题
[爬虫 | Python]解决'Requests Max Retries Exceeded With Url in Python'报错的问题 背景 解决方案 一.普遍方案 细致方案 一.问题重述 1. ...
- Python 中错误 ConnectionError: Max retries exceeded with url
文章目录 使用 Retry 对象进行回退重试 使用 try/except 语句在发生错误时不重试 禁用 SSL 证书验证 使用 time.sleep() 方法实现请求之间的延迟 重复请求直到成功响应 ...
- 【python爬虫错误】Max retries exceeded with url
Max retries exceeded with url 寻找可用的ip 寻找可用的ip import time from lxml import html # 把lxml是解析xml语言的库 et ...
- python3 错误 Max retries exceeded with url 解决方法
在爬取时出现这种错误, ConnectionError: HTTPConnectionPool(host='xxx.xx.xxx.xxx', port=xxxx): Max retries excee ...
- python HTTPConnectionPool(host:XX)Max retries exceeded with url
python 出现HTTPConnectionPool(host:XX)Max retries exceeded with url问题 在每次数据传输前客户端要和服务器建立TCP连接,为节省传输消耗, ...
- 【Bug】python requests发起请求,报“Max retries exceeded with url”
在本地机器上,高频率重复调用一个API接口,出现"Max retries exceeded with url",拒绝连接的情况. 楼主讲一下,遇到这个bug的过程: 在服务器上开发 ...
- python requests max retries_python requests报Max retries exceeded with url异常
项目中有个模块是定时获取设备状态的,通过设备的http请求访问获取返回的状态码,然后根据状态码检测设备是否在线.但是最近发现连接后出现了偶尔连接不上的情况,报错如下: 2018-06-14 15:51 ...
- HTTPConnectionPool(host=‘localhost‘, port=28333): Max retries exceeded with url: /events (Caused by
错误: 训练神经网络的时候报错如下: HTTPConnectionPool(host='localhost', port=28333): Max retries exceeded with url: ...
- Max retries exceeded with URL in requests
爬虫的时候遇到的一个错误 Max retries exceeded with URL in requests requests.exceptions.ConnectionError: HTTPSCon ...
最新文章
- Linux下gdb调试工具的使用
- 逆袭“潮牌”后,李宁离安踏还有多远?
- 东北大学 计算机技术导师,报考东北大学 计算机技术 329分 求调剂相关专业
- java map同步访问_同步 - Java synchronized块与Collections.synchronizedMap
- JAVA和C++内部类
- hdu1114Piggy-Bank(完全背包)
- jfinal项目tomcat下部署
- win10更改登录密码
- C#中Panel控件和GroupBox控件(未完成)
- mysql删除图书信息,图书管理系统(一):出版社列表增加、删除和编辑
- 再谈js拖拽(二)仿iGoogle自定义首页模块拖拽
- 选个关注热度上升的大数据工具学习下吧
- 写在第35个教师节到来时的话——对我国现阶段职业教育改革的总体论述
- pycharm 2017.3破解方法
- 网络基础知识——交换机路由器
- LaTeX常用操作:添加标题、作者、时间、摘要、标题、段落、目录、字体、引用、脚注、图片\表格插入、数学符号、公式、交叉引用等
- CCS5.1/5.5/6下载地址
- YOLOv1 学习笔记
- 【亚马逊运营】几点选品的建议卖家们都注意了吗?
- 金蝶专业版怎么反过账当月_金蝶专业版怎么反过账