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 ...
随机推荐
- springboot整合jetty
1.jetty介绍 通常我们进行Java Web项目开发,必须要选择一种服务器来部署并运行Java应用程序,Tomcat和Jetty作为目前全球范围内最著名的两款开源servlet容器,该怎么选呢. ...
- Spring Cloud 和dubbo
一.SpringCloud微服务技术简介 Spring Cloud 作为Java 语言的微服务框架,它依赖于Spring Boot,有快速开发.持续交付和容易部署等特点.Spring Cloud 的组 ...
- 【Office】【Excel】将多个工作表合为一个工作表
在工作表中按下alt+F11打开vba编辑窗口,在菜单栏中选择[插入]=>[模板],将下面的代码粘贴过去,然后运行即可 点击查看代码 Sub 合并当前工作簿下的所有工作表() On Error ...
- 【Spark】【RDD】从内存(集合)创建RDD
val list = List(1,2,3) var rdd = sc.parallelize(list) rdd.partitions.size 通过调用SparkContext的paralleli ...
- [BUUCTF]PWN——babyheap_0ctf_2017
[BUUCTF]PWN--babyheap_0ctf_2017 附件 步骤: 例行检查,64位,保护全开 试运行一下程序,看到这个布局菜单,知道了这是一道堆的题目,第一次接触堆的小伙伴可以去看一下这个 ...
- MySQL 的日志:binlog
前言:binlog 用于记录数据库执行写入性操作的日志信息,以二进制的形式保留在磁盘中.它是由 Server 层进行记录的,使用任何存储引擎都会产生 binlog. 实验准备 我们通过 Docker ...
- CF1064A Make a triangle! 题解
Content 有三条长度分别为 \(a,b,c\) 的线段.你可以在一个单位时间内将一条线段的长度增加 \(1\),试求出能使这三条线段组成一个三角形的最短时间. 数据范围:\(1\leqslant ...
- SP8374 PARKET1 - PARKET 题解
Content 有一个 \(l\times w\) 大小的网格,其四周均被染成了红色,其余部分是棕色,已知红色网格与棕色网格的数量,求 \(l\) 与 \(w\) 的值. Solution 接下来给各 ...
- lightgallery 使用
用途 图片预览,支持多图片滑动预览 git 地址 https://github.com/sachinchoolur/lightgallery.js 代码 # idnex.html <script ...
- layui踩过的坑
layui 表格合计行取整 原代码:(文件位置:..\layui\lay\modules\table.js) var e=o.totalRowText||"",i=parseFlo ...