教你如何使用Python下载B站视频的详细教程
前言
众所周知,网页版的B站无法下载视频,然本人喜欢经常在B站学习,奈何没有网时,无法观看视频资源,手机下载后屏幕太小又不想看,遂写此程序以解决此问题
步骤
话不多说,进入正题
1.在电脑上下载python的开发环境,点一下,观看具体步骤
2.下载pycharm开发工具,点一下观看具体步骤
3.同时按键盘上的win键与r键,在弹出的对话框中输入cmd
点击确定进入cmd命令行,在里面输入pip install you-get,之后按键盘enter键,进行you-get的下载,下载完后退出cmd
4.打开pycharm开发工具,新建一个python file命名为bilibili,把下面的代码复制进去,关于pycharm开发工具的使用,点我一下,观看教程
import sys import you_get from multiprocessing import Pool #url ='你要下载的视频链接' #path='你要把视频保存到哪里' url = 'https://www.bilibili.com/video/BV13s411371G?p=' path = 'D:/Bzhan/openstack' total=14 def down1(): start_url = url path1 = path for i in range(1, 3, 1): url1 = start_url + str(i) download(url1, path1) def down2(): start_url = url path1 = path for i in range(3, 5, 1): url1 = start_url + str(i) download(url1, path1) def down3(): start_url = url path1 = path for i in range(5, 7, 1): url1 = start_url + str(i) download(url1, path1) def down4(): start_url = url path1 = path for i in range(7, 9, 1): url1 = start_url + str(i) download(url1, path1) def down5(): start_url = url path1 = path for i in range(9, 11, 1): url1 = start_url + str(i) download(url1, path1) def down6(): start_url = url path1 = path for i in range(11, 13, 1): url1 = start_url + str(i) download(url1, path1) def down7(): start_url = url path1 = path for i in range(13, 15, 1): url1 = start_url + str(i) download(url1, path1) def down8(): start_url = url path1 = path for i in range(35, 40, 1): url1 = start_url + str(i) download(url1, path1) def download(url, path): sys.argv = ['you-get', '-o', path, url] you_get.main() def main(): po = Pool(8) po.apply_async(down1) po.apply_async(down2) po.apply_async(down3) po.apply_async(down4) po.apply_async(down5) po.apply_async(down6) po.apply_async(down7) po.apply_async(down8) po.close() po.join() if __name__ == '__main__': main()
接下来就可以运行程序,下载视频了
5.下面这个程序也能实现下载B站视频的功能,不过下载速度简直无语,称的上龟速
import you_get import sys import you_get def download(url,path): sys.argv=['you-get','-o',path,url] you_get.main() if __name__=='__main__': start_url='https://www.bilibili.com/video/BV13s411371G?p=' path = 'D:/Bzhan/openstack' for i in range(1,14,1): url=start_url +str(i) download(url,path)
到此这篇关于教你如何使用Python下载B站视频的详细教程的文章就介绍到这了,更多相关Python下载B站视频内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!
赞 (0)