Python 请求中的 url 超出了最大重试次数

Sir*_*org 3 python request httpurlconnection web-scraping python-requests

我尝试向此 URL 发送请求:站点 URL

并使用以下代码进行简单的页面读取:

import requests
url_1 = 'http://www.dsit.org.ir/?cmd=page&Cid=92&title=Kontakt&lang=fa'
print(requests.get(url_1).text)
Run Code Online (Sandbox Code Playgroud)

但我收到这个错误:

requests.exceptions.ConnectionError: HTTPConnectionPool(host='www.srgfesrsergserg.com', port=80): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000008EC69AAA90>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))
Run Code Online (Sandbox Code Playgroud)

该站点非常基础,没有特殊的安全措施。另外,我只请求过一次

一切都很好,我用Request-html很容易打开这个页面,但我不知道问题出在哪里!

小智 7

添加标题。

伪装浏览器。

import requests

headers = {
    'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36'}

url_1 = 'http://www.dsit.org.ir/?cmd=page&Cid=92&title=Kontakt&lang=fa'

print(requests.get(url=url_1, headers=headers).text)
Run Code Online (Sandbox Code Playgroud)