python实战-B站视屏

import requests
import re
import you_get
import sys
video_name = input('请输入你想要看的内容:')
page = input('你想观赏第几页:')
url = 'https://search.bilibili.com/video?keyword={}&page={}'.format(video_name, page)
path = 'E:/哔哩哔哩小视频'  # 视频保存的路径
response = requests.get(url).content.decode('utf-8')  # 获得页面内容
# print(response)
video_url = re.findall('a href="//www.bilibili.com/video/(.*?)?from=search', response)  # 抓取每页所有视频的播放地址
video_names = re.findall('<a title="(.*?)"', response)  # 抓取每页所有视频的名字
urls = []
# for i in video_names:
#     print(i)
j = 0
for i in video_url:
    urls.append('https://www.bilibili.com/video/' + i[:-1])  # 拼接小视频完整的播放地址
for i in video_names:
    print('%d:' % (j + 1) + i, sep="", end=" ")
    print('观看地址:' + urls[j])
    j += 1
video_num = int(input('你想下载第几个视频:'))


sys.argv = ['you-get', '-o', path, urls[video_num-1]]

you_get.main()
print('下载成功!')

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值