[WinError 10054] 远程主机强迫关闭了一个现有的连接。
Traceback (most recent call last):
File "E:\Python Practice\downpic\yande.py", line 34, in get_response
response = urllib.request.urlopen(req)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\urllib\request.py", line 228, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\urllib\request.py", line 531, in open
response = self._open(req, data)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\urllib\request.py", line 549, in _open
'_open', req)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\urllib\request.py", line 509, in _call_chain
result = func(*args)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\urllib\request.py", line 1347, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\urllib\request.py", line 1322, in do_open
r = h.getresponse()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\http\client.py", line 1246, in getresponse
response.begin()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\http\client.py", line 297, in begin
version, status, reason = self._read_status()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\http\client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\socket.py", line 575, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\random.py", line 253, in choice
i = self._randbelow(len(seq))
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\random.py", line 230, in _randbelow
r = getrandbits(k) # 0 <= r < 2**k
ValueError: number of bits must be greater than zero
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Python Practice\downpic\yande.py", line 127, in <module>
get_proxy()
File "E:\Python Practice\downpic\yande.py", line 58, in get_proxy
response = get_response(req)
File "E:\Python Practice\downpic\yande.py", line 46, in get_response
change_proxy()
File "E:\Python Practice\downpic\yande.py", line 75, in change_proxy
proxy = random.choice(proxies)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\random.py", line 255, in choice
raise IndexError('Cannot choose from an empty sequence')
IndexError: Cannot choose from an empty sequence