Last active
April 15, 2023 16:32
-
-
Save Sg4Dylan/94565e6629792264ba0b22ff707e088c to your computer and use it in GitHub Desktop.
通过You-get批量下载Bilibili合集视频
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#coding:utf-8 | |
# Author: Sg4Dylan --<sg4dylan#gmail.com> | |
# Purpose: A simple script to download video from Bilibili | |
# Created: 08/07/2016 | |
import sys | |
from subprocess import call | |
def check_and_go(args): | |
try: | |
if not (args[0] and args[1]): | |
usage_tip(0) | |
if "index" in args[0]: | |
usage_tip(2) | |
else: | |
if args[1] == 0: | |
usage_tip(2) | |
else: | |
bilibili_down_them_all(args[0],int(args[1])) | |
except IndexError: | |
usage_tip(0) | |
except ValueError: | |
usage_tip(1) | |
def bilibili_down_them_all(link,p_count): | |
for i in range(1,p_count+1): | |
print("Start downloading...\n%s\n" % link) | |
call("you-get -d " + link + "index_" + str(i) + ".html", shell=True) | |
def usage_tip(exit_flag): | |
if exit_flag == 0: | |
print("Missing parameters !\n") | |
else: | |
print("Please check you parameters !\n") | |
print("Usage: python bilibili_download_them_all.py [PageLink] [VideoCount]") | |
print("Example: python bilibili_download_them_all.py http://www.bilibili.com/video/av4432868/ 9") | |
sys.exit(exit_flag) | |
if __name__ == "__main__": | |
check_and_go(sys.argv[1:]) |
我在下载的那一页有24个视频,成功下载了8个之后报错了urllib.error.URLError: <urlopen error EOF occurred in violation of protocol
你好,回车运行后出现直接跳出源码页面出来。我是用于以下地址:https://www.bilibili.com/video/av13427326/?from=search&seid=15799877929454579320。然后命令提示窗口出现seid不是命令也不是可以执行程序。应该如何修复?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
请问下弄好之后的输出文件在哪里啊
MacBook-Air:~ jiangpeifeng$ cd desktop
MacBook-Air:desktop jiangpeifeng$ python3 bilibili_download_them_all.py https://www.bilibili.com/video/av11026232/ 2
Start downloading...
https://www.bilibili.com/video/av11026232/
[DEBUG] url_locations: https://www.bilibili.com/video/av11026232/index_1.html
you-get: version 0.4.915, a tiny downloader that scrapes the web.
you-get: Namespace(URL=['https://www.bilibili.com/video/av11026232/index_1.html'], cookies=None, debug=True, extractor_proxy=None, force=False, format=None, help=False, http_proxy=None, info=False, input_file=None, itag=None, json=False, no_caption=False, no_merge=False, no_proxy=False, output_dir='.', output_filename=None, password=None, player=None, playlist=False, socks_proxy=None, stream=None, timeout=600, url=False, version=False)
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1318, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1400, in connect
server_hostname=server_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 401, in wrap_socket
_context=self, _session=session)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 808, in init
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 1061, in do_handshake
self._sslobj.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 683, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/you-get", line 11, in
sys.exit(main())
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/you_get/main.py", line 92, in main
main(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/you_get/common.py", line 1362, in main
script_main(any_download, any_download_playlist, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/you_get/common.py", line 1270, in script_main
**extra
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/you_get/common.py", line 1072, in download_main
download(url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/you_get/common.py", line 1355, in any_download
m.download(url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/you_get/extractor.py", line 46, in download_by_url
self.prepare(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/you_get/extractors/bilibili.py", line 108, in prepare
self.url = url_locations([self.url])[0]
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/you_get/common.py", line 522, in url_locations
response = urlopen_with_retry(request.Request(url))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/you_get/common.py", line 346, in urlopen_with_retry
return request.urlopen(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 544, in _open
'_open', req)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1361, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1320, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)>
Start downloading...
https://www.bilibili.com/video/av11026232/
[DEBUG] url_locations: https://www.bilibili.com/video/av11026232/index_2.html
you-get: version 0.4.915, a tiny downloader that scrapes the web.
you-get: Namespace(URL=['https://www.bilibili.com/video/av11026232/index_2.html'], cookies=None, debug=True, extractor_proxy=None, force=False, format=None, help=False, http_proxy=None, info=False, input_file=None, itag=None, json=False, no_caption=False, no_merge=False, no_proxy=False, output_dir='.', output_filename=None, password=None, player=None, playlist=False, socks_proxy=None, stream=None, timeout=600, url=False, version=False)
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1318, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1400, in connect
server_hostname=server_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 401, in wrap_socket
_context=self, _session=session)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 808, in init
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 1061, in do_handshake
self._sslobj.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 683, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/you-get", line 11, in
sys.exit(main())
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/you_get/main.py", line 92, in main
main(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/you_get/common.py", line 1362, in main
script_main(any_download, any_download_playlist, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/you_get/common.py", line 1270, in script_main
**extra
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/you_get/common.py", line 1072, in download_main
download(url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/you_get/common.py", line 1355, in any_download
m.download(url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/you_get/extractor.py", line 46, in download_by_url
self.prepare(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/you_get/extractors/bilibili.py", line 108, in prepare
self.url = url_locations([self.url])[0]
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/you_get/common.py", line 522, in url_locations
response = urlopen_with_retry(request.Request(url))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/you_get/common.py", line 346, in urlopen_with_retry
return request.urlopen(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 544, in _open
'_open', req)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1361, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1320, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)>
MacBook-Air:desktop jiangpeifeng$