前言
眾所周知,網(wǎng)頁版的B站無法下載視頻,然本人喜歡經(jīng)常在B站學(xué)習(xí),奈何沒有網(wǎng)時(shí),無法觀看視頻資源,手機(jī)下載后屏幕太小又不想看,遂寫此程序以解決此問題
步驟
話不多說,進(jìn)入正題
1.在電腦上下載python的開發(fā)環(huán)境,點(diǎn)一下,觀看具體步驟
2.下載pycharm開發(fā)工具,點(diǎn)一下觀看具體步驟
3.同時(shí)按鍵盤上的win鍵與r鍵,在彈出的對(duì)話框中輸入cmd
點(diǎn)擊確定進(jìn)入cmd命令行,在里面輸入pip install you-get,之后按鍵盤enter鍵,進(jìn)行you-get的下載,下載完后退出cmd
4.打開pycharm開發(fā)工具,新建一個(gè)python file命名為bilibili,把下面的代碼復(fù)制進(jìn)去,關(guān)于pycharm開發(fā)工具的使用,點(diǎn)我一下,觀看教程
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()
接下來就可以運(yùn)行程序,下載視頻了
5.下面這個(gè)程序也能實(shí)現(xiàn)下載B站視頻的功能,不過下載速度簡(jiǎn)直無語,稱的上龜速
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)
到此這篇關(guān)于教你如何使用Python下載B站視頻的詳細(xì)教程的文章就介紹到這了,更多相關(guān)Python下載B站視頻內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
您可能感興趣的文章:- 用基于python的appium爬取b站直播消費(fèi)記錄
- 如何用python抓取B站數(shù)據(jù)
- 基于python對(duì)B站收藏夾按照視頻發(fā)布時(shí)間進(jìn)行排序的問題
- 如何使用python爬取B站排行榜Top100的視頻數(shù)據(jù)