quot;requests.exceptions.ConnectionError: (#39;Connection aborted.#39;, RemoteDisconnected(#39;Remote end closed connection without response#39;,))quot;(请求。例外。连接错误:(#39;连接已中止。#39;,远程断开连接(#39;远程端关闭的连接无响应#39;,)) - IT屋-程序员软件开发技术
问题描述
我正在尝试连接到https://apis.digital.gob.cl/fl/feriados/2020,但在与其他URL完美配合的脚本上遇到requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
错误。
代码:
import requests
response = requests.get('https://apis.digital.gob.cl/fl/feriados/2020')
print(response.status_code)
推荐答案
问题是网站没有正确的User-Agent
过滤请求,所以只使用mdn:
requests.get("https://apis.digital.gob.cl/fl/feriados/2020", headers={
"User-Agent" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"
})
这篇关于请求。例外。连接错误:(';连接已中止。';,远程断开连接(';远程端关闭的连接无响应';,)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!