gpt4 book ai didi

python - "requests.exceptions.ConnectionError: (' 连接中止。 ', RemoteDisconnected(' 远端关闭连接无响应 ',))"

转载 作者:行者123 更新时间:2023-12-04 14:11:52 29 4
gpt4 key购买 nike

我正在尝试连接到 https://apis.digital.gob.cl/fl/feriados/2020但我收到了 requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))与其他 URL 完美配合的脚本上的错误。
编码:

import requests


response = requests.get('https://apis.digital.gob.cl/fl/feriados/2020')
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"
})

关于python - "requests.exceptions.ConnectionError: (' 连接中止。 ', RemoteDisconnected(' 远端关闭连接无响应 ',))",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63648752/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com