urllib.error.URLError: <Fehler beim Öffnen der URL [Errno 11002] getaddrinfo fehlgeschlagen>?

Also, mein Code ist nur 4 Zeilen. Ich versuche, eine Verbindung zu einer Website herzustellen. Was ich danach versuche, ist irrelevant, da der Fehler ohne die anderen Codes aufgetreten ist.

import urllib.request
from bs4 import BeautifulSoup 

html=urllib.request.urlopen('http://python-data.dr-chuck.net/known_by_Fikret.html').read()
soup=BeautifulSoup(html,'html.parser')

und der Fehler (kurz zusammengefasst):

for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11002] getaddrinfo failed
During handling of the above exception, another exception occurred:
urllib.error.URLError: <urlopen error [Errno 11002] getaddrinfo failed>

Hier ist, was ich versucht habe.

Ich habe nach dem Fehler gesucht, der "urlopen error [Errno 11002]" bei Google und insbesondere bei Stackoverflow zurückgegeben wurde. Es wurde nichts Hilfreiches zurückgegeben. (Tatsächlich wurden zu diesem Fehler nicht viele Fragen gestellt. 11002 wurde gestellt.)So Dann versuche ich, das Website-Argument zu ersetzen (d. H. "http: //python-data.dr-chuck.net/known_by_Fikret.htm ") innerhalb der urlopen Funktion mit einer anderen Website"http: //www.pythonlearn.com/code/urllinks.p ". Und es hat einwandfrei funktioniert. Es kommt kein Fehler. Also ich denke, dieser Fehler muss etwas mit dieser bestimmten Website per se zu tun haben. Die Website ist etwas dynamisch, womit ich meine, dass sich ihr Inhalt ändern und in eine ganz andere Sache verwandeln wird. Aber ich weiß nicht mehr, als nur zu beschreiben, was ich gesehen habe.

und die längere und vollständige Version des Fehlers:

Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\urllib\request.py", line 1240, in do_open
h.request(req.get_method(), req.selector, req.data, headers)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\http\client.py", line 1083, in request
self._send_request(method, url, body, headers)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\http\client.py", line 1128, in _send_request
self.endheaders(body)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\http\client.py", line 1079, in endheaders
self._send_output(message_body)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\http\client.py", line 911, in _send_output
self.send(msg)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\http\client.py", line 854, in send
self.connect()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\http\client.py", line 826, in connect
(self.host,self.port), self.timeout, self.source_address)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\socket.py", line 693, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\socket.py", line 732, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11002] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:/baiduyundownload/Tempo/Active/Python/Python Examples/Fileanalysis11111.py", line 4, in <module>
html=urllib.request.urlopen('http://python-data.dr-chuck.net/known_by_Fikret.html').read()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\urllib\request.py", line 162, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\urllib\request.py", line 465, in open
response = self._open(req, data)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\urllib\request.py", line 483, in _open
'_open', req)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\urllib\request.py", line 443, in _call_chain
result = func(*args)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\urllib\request.py", line 1268, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\urllib\request.py", line 1242, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 11002] getaddrinfo failed>

Antworten auf die Frage(4)

Ihre Antwort auf die Frage