Python开发笔记|Python requests ConnectionError报错( connection aborted BadStatusLine)
报错信息:
文章图片
raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine("''", ))
涉及代码
data = https://www.it610.com/article/{"host":host,"key":key,"value":value,"dns":ip} res = requests.post(url=url,json = data)
方法1: 加重试
requests.adapters.DEFAULT_RETRIES = 5
方法2:加header
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.0;
WOW64;
rv:24.0) Gecko/20100101 Firefox/24.0'} res = requests.post(url=url,json = data,headers=headers)
方法3: curl
1,2 都不行,curl命令,发现报错:
Empty reply from server
【Python开发笔记|Python requests ConnectionError报错( connection aborted BadStatusLine)】答案: You get this error when your Python client receives an empty response (header /body).
python - Connection aborted.', BadStatusLine("''",) on server? - Stack Overflow
推荐阅读
- Python开发笔记|[Python]Curl命令模拟与json解析
- Python|【Python】Python学习(十一)错误与异常
- 解决telnet时no route to host的错误
- 杂记|深大计网实验 4(Socket 网络编程)
- Python学习|Python学习-错误和异常的处理
- Python学习笔记|Python基础教程(异常处理)
- 看这一篇就够了!Python Openpyxl完整开发实例分析
- python|Kafka
- C语言与C++编程|马斯克(我是 Rust 粉丝,但为了性能会选择 C语言)