|
发表于 2020-10-28 15:59:49
|
显示全部楼层
请问为什么会报错:
Traceback (most recent call last):
File "D:\Python-3.8\lib\urllib\request.py", line 1350, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "D:\Python-3.8\lib\http\client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "D:\Python-3.8\lib\http\client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "D:\Python-3.8\lib\http\client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "D:\Python-3.8\lib\http\client.py", line 1010, in _send_output
self.send(msg)
File "D:\Python-3.8\lib\http\client.py", line 950, in send
self.connect()
File "D:\Python-3.8\lib\http\client.py", line 1424, in connect
self.sock = self._context.wrap_socket(self.sock,
File "D:\Python-3.8\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "D:\Python-3.8\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "D:\Python-3.8\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\zjm16\Desktop\爬虫.py", line 69, in <module>
download_mm()
File "C:\Users\zjm16\Desktop\爬虫.py", line 57, in download_mm
page_num = int(get_page(url))
File "C:\Users\zjm16\Desktop\爬虫.py", line 20, in get_page
html = url_open(url).decode('utf-8')
File "C:\Users\zjm16\Desktop\爬虫.py", line 13, in url_open
response = urllib.request.urlopen(req)
File "D:\Python-3.8\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "D:\Python-3.8\lib\urllib\request.py", line 525, in open
response = self._open(req, data)
File "D:\Python-3.8\lib\urllib\request.py", line 542, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "D:\Python-3.8\lib\urllib\request.py", line 502, in _call_chain
result = func(*args)
File "D:\Python-3.8\lib\urllib\request.py", line 1393, in https_open
return self.do_open(http.client.HTTPSConnection, req,
File "D:\Python-3.8\lib\urllib\request.py", line 1353, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [WinError 10054] 远程主机强迫关闭了一个现有的连接。>
|
|