python requests发起请求,报“Max retries exceeded with url”
需要高频率重复调用一个接口,偶尔会出现“Max retries exceeded with url”
在使用requests多次访问同一个ip时,尤其是在高频率访问下,http连接太多没有关闭导致的
Max retries exceeded with url 的错误
解决方法:调用完之后,将连接关闭
try:
if type == 'JSON':
res = requests.post(url, headers=headers, json=parm, cookies=cookies)
else:
res = requests.post(url, headers=headers, data=parm, cookies=cookies)
logger.info('send_request_json_data_发起post请求,url为:{0},接口传入的参数:{1}'.format(url, parm))
# 请求完成后,关闭连接(若对同一个request高频率发起时,可能会出现Max retries exceeded with url)
res.close()
except requests.RequestException as e:
logger.error("send_request_json_data_post请求出现异常:{0}".format(e))
经过观察发现,使用后关闭res.close(),可以解决Max retries exceeded with url 的错误
参考:https://blog.csdn.net/weixin_43932214/article/details/89554963?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-4.no_search_link&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-4.no_search_link
python requests发起请求,报“Max retries exceeded with url”的更多相关文章
- centos7中python3.6报错ModuleNotFoundError: No module named '_ssl' 或者 Max retries exceeded with url: / (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",))
如果在运行爬虫时报此错:requests.exceptions.SSLError: HTTPSConnectionPool(host='www.baidu.com', port=443): Max r ...
- windows环境pip安装时一直报错Could not fetch URL https://pypi.org/simple/xrld/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url:
最近项目不忙了~~有开始专研的python大业,上来想用pip安装一个第三方的库,就一直报错: Could not fetch URL https://pypi.org/simple/xrld/: T ...
- requests.exceptions.SSLError……Max retries exceeded with url错误求助!!!
import requests head = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Appl ...
- 关于python3.6上传文件时报错:HTTPSConnectionPool(host='***.org', port=443): Max retries exceeded with url: /post (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAIL解决办法
第一个报错: 最近在练习post请求中上传文件时遇到了一个奇葩事情,两台电脑上写了一模一样的代码,一个运行正常,另一个一片红. 最后了解了一下原因以及解决办法.先记录下关键代码: files = {& ...
- 解决Max retries exceeded with url的问题
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='itunes.apple.com', port=443): Max ret ...
- HTTPConnectionPool(host='xx.xx.xx.xx', port=xx): Max retries exceeded with url:(Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x0000015A25025EB8>...))
HTTPConnectionPool(host='xx.xx.xx.xx', port=xx): Max retries exceeded with url:(Caused by ConnectTim ...
- scrapy::Max retries exceeded with url
运行scrapy时出错这个错误:Max retries exceeded with url解决方法: img1=requests.get(url=aa,headers=header1,timeout= ...
- Max retries exceeded with url
78 Traceback (most recent call last): File "thread072413.py", line 163, in <module> ...
- HTTPConnectionPool(host:XX)Max retries exceeded with url 解决方法
爬虫多次访问同一个网站一段时间后会出现错误 HTTPConnectionPool(host:XX)Max retries exceeded with url '<requests.package ...
随机推荐
- angular过滤器在html和js中的使用
在HTML中使用格式为:{{数据 | 过滤器名称:条件一:条件二--}}:过滤条件间使用:隔开 例如: 在代码中一般格式为: 变量 = $filter("过滤器名称")(被过滤数 ...
- 「Python实用秘技01」复杂zip文件的解压
本文完整示例代码及文件已上传至我的Github仓库https://github.com/CNFeffery/PythonPracticalSkills 这是我的新系列文章「Python实用秘技」的第1 ...
- C++内存管理:简易内存池的实现
什么是内存池? 在上一篇 C++内存管理:new / delete 和 cookie中谈到,频繁的调用 malloc 会影响运行效率以及产生额外的 cookie, 而内存池的思想是预先申请一大块内存, ...
- 如何为Dash/Zeal生成c++ 文档: 以abseil文档为例
目录 1. 软件安装 2 Sample源文件下载: 3. 生成步骤 3.1 使用doxygen生成html文件 3.2 使用docsetutil 生成 dash/Zeal 格式 1. 软件安装: 1. ...
- Redis cluster 集群报错合集
目录 一.连接集群操作报错(error)MOVED 二.集群关闭后重启报错 三.Redis (error) NOAUTH Authentication required 四.Redis集群使用中突然挂 ...
- ciscn_2019_es_7
这是我第一次见到srop的用法的题目,于是在此记录方便以后的复习 拿到程序例行检查 将程序放入ida中 可以看到栈的大小是0x10,却可以显示出0x30的内容,所以我们可以通过这个溢出泄露出/bin/ ...
- 0RAYS元旦招新赛
一共有4道pwn题,题目不算难,但是挺考验调试能力的. pie 一个main函数就四次溢出... 第一次leak canary,第二次leak libc,第三次直接覆盖返回地址为one_gadgets ...
- RabbitMQ,RocketMQ,Kafka 消息模型对比分析
消息模型 消息队列的演进 消息队列模型 发布订阅模型 RabbitMQ的消息模型 交换器的类型 direct topic fanout headers Kafka的消息模型 RocketMQ的消息模型 ...
- Table.ReorderColumns移动…Reorder…(Power Query 之 M 语言)
数据源: 至少两列 目标: 列顺序重新排列 操作过程: 选取待移动的列>鼠标拖放列标题 选取待移动的列>[转换]>[移动]>选取 M公式: = Table.ReorderCo ...
- IDEA 2021.2.1 破解版下载_激活安装图文教程(永久激活,亲测有效)
1.IntelliJ IDEA 2021 链接:https://pan.baidu.com/s/1Pwz3GrrkJdDZzg-wg5UjMw 提取码:56o6 无限重置 30 天试用期补丁 链接:h ...