|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
按照甲鱼老师,视频一字不落敲的,为啥我的就跑不起来呢
import urllib.request
response = urllib.request.urlopen("http://www.fishc.com")
html = response.read()
print(html)
C:\Python38\python.exe C:/Python38/demo.py
Traceback (most recent call last):
File "C:\Python38\Lib\urllib\request.py", line 1317, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "C:\Python38\Lib\http\client.py", line 1230, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Python38\Lib\http\client.py", line 1276, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Python38\Lib\http\client.py", line 1225, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Python38\Lib\http\client.py", line 1004, in _send_output
self.send(msg)
File "C:\Python38\Lib\http\client.py", line 944, in send
self.connect()
File "C:\Python38\Lib\http\client.py", line 915, in connect
self.sock = self._create_connection(
File "C:\Python38\Lib\socket.py", line 807, in create_connection
raise err
File "C:\Python38\Lib\socket.py", line 796, in create_connection
sock.connect(sa)
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Python38/demo.py", line 3, in <module>
response = urllib.request.urlopen("http://www.fishc.com")
File "C:\Python38\Lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "C:\Python38\Lib\urllib\request.py", line 525, in open
response = self._open(req, data)
File "C:\Python38\Lib\urllib\request.py", line 542, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "C:\Python38\Lib\urllib\request.py", line 502, in _call_chain
result = func(*args)
File "C:\Python38\Lib\urllib\request.py", line 1346, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "C:\Python38\Lib\urllib\request.py", line 1320, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond>
Process finished with exit code 1
|
|