Bilibili_video_download-GUI 下载多P视频时发生socket.gaierror: [Errno 11004] getaddrinfo failed和urllib.error.URLError: <urlopen error [Errno 11004] getaddrinfo failed>
不知道哪里出了错误?是url还是服务器拒绝服务?
GUI可以下载一部分视频,但是有一部分视频没有下载成功,多次测试发现,每次下载失败的视频是随机的,成功下载的视频也是随机的。希望解决这个问题。
具体提示如下:
D:\Bilibili_video_download>"D:/Program Files/Python37/python.exe" d:/Bilibili_video_download/bilibili_video_download-GUI.py
Exception in thread Thread-74:
Traceback (most recent call last):
File "D:\Program Files\Python37\lib\urllib\request.py", line 1317, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "D:\Program Files\Python37\lib\http\client.py", line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File "D:\Program Files\Python37\lib\http\client.py", line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "D:\Program Files\Python37\lib\http\client.py", line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "D:\Program Files\Python37\lib\http\client.py", line 1016, in _send_output
self.send(msg)
File "D:\Program Files\Python37\lib\http\client.py", line 956, in send
self.connect()
File "D:\Program Files\Python37\lib\http\client.py", line 928, in connect
(self.host,self.port), self.timeout, self.source_address)
File "D:\Program Files\Python37\lib\socket.py", line 707, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "D:\Program Files\Python37\lib\socket.py", line 748, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11004] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Program Files\Python37\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "D:\Program Files\Python37\lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "d:/Bilibili_video_download/bilibili_video_download-GUI.py", line 147, in down_video
urllib.request.urlretrieve(url=i, filename=os.path.join(currentVideoPath, r'{}.flv'.format(title)),reporthook=Schedule_cmd) # 写成mp4也行 title + '-' + num + '.flv'
File "D:\Program Files\Python37\lib\urllib\request.py", line 247, in urlretrieve
with contextlib.closing(urlopen(url, data)) as fp:
File "D:\Program Files\Python37\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "D:\Program Files\Python37\lib\urllib\request.py", line 525, in open
response = self._open(req, data)
File "D:\Program Files\Python37\lib\urllib\request.py", line 543, in _open
'_open', req)
File "D:\Program Files\Python37\lib\urllib\request.py", line 503, in _call_chain
result = func(*args)
File "D:\Program Files\Python37\lib\urllib\request.py", line 1345, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "D:\Program Files\Python37\lib\urllib\request.py", line 1319, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 11004] getaddrinfo failed>
可能是某个软件包的版本问题,本机windows 安装python3.7, 运行pip3 list 结果如下,供排查错误参考:
$ pip3 list
Package Version
pip 19.0.3
altgraph 0.16.1
astroid 2.3.2
beautifulsoup4 4.8.1
BiliUtil 0.2.1
certifi 2019.9.11
chardet 3.0.4
Click 7.0
colorama 0.4.1
comtypes 1.1.7
decorator 4.4.0
fake-useragent 0.1.11
future 0.18.1
gql 0.1.0
graphql-core 2.2.1
graphqlclient 0.2.4
idna 2.8
imageio 2.4.1
imageio-ffmpeg 0.3.0
isort 4.3.21
lazy-object-proxy 1.4.2
lxml 4.4.1
macholib 1.11
mccabe 0.6.1
moviepy 1.0.1
numpy 1.17.3
packaging 19.2
pefile 2019.4.18
Pillow 6.2.0
pip 19.3.1
proglog 0.1.9
promise 2.2.1
PyInstaller 3.5
pylint 2.4.3
pyparsing 2.4.2
PyQt5 5.13.0
PyQt5-sip 12.7.0
pyqt5-tools 5.13.0.1.5
python-dotenv 0.10.3
pywin32 225
pywin32-ctypes 0.2.0
requests 2.22.0
Rx 1.6.1
selenium 3.141.0
setuptools 40.8.0
sgqlc 8.1
sip 5.0.0
six 1.12.0
soupsieve 1.9.4
toml 0.10.0
tqdm 4.36.1
typed-ast 1.4.0
urllib3 1.25.6
websocket-client 0.56.0
websockets 8.0.2
wrapt 1.11.2
xlwings 0.16.0