from DrissionPage._pages.chromium_page import ChromiumPage
page = ChromiumPage()
page.listen.start('video/BV1qu411b7EY')
page.get('https://www.bilibili.com/video/BV1qu411b7EY/?p=7')
resp = page.listen.wait()
info = resp.response.body
print(info)
headers = {
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'accept-language': 'zh-CN,zh;q=0.9',
'cache-control': 'max-age=0',
# 'cookie': "buvid3=F7CFC4A8-9D7A-09BF-9BA7-3D7F4E3B3D4902388infoc; b_nut=1725671802; b_lsid=1DE87172_191CA0E1005; _uuid=283A2492-C1E2-AC92-2F108-4E1D3C3E79BA04939infoc; CURRENT_FNVAL=4048; bili_ticket=eyJhbGciOiJIUzI1NiIsImtpZCI6InMwMyIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MjU5MzEwMDMsImlhdCI6MTcyNTY3MTc0MywicGx0IjotMX0.0-Bn4B3himQ7aN1R09CP-oqQ9MGhISsIgDLII0vnWkg; bili_ticket_expires=1725930943; buvid_fp=2fd96b20892f4ae572daad1cd1ad1f26; buvid4=57818A6E-FEA2-82DD-2303-F7D4AA7381B203733-024090701-XY5a6mPyRvD3DJfqtZUleA%3D%3D; rpdid=|(J|lY)k~Rkl0J'u~klY~u)|l; sid=4rjw28k0",
'priority': 'u=0, i',
'sec-ch-ua': '"Not)A;Brand";v="99", "Google Chrome";v="127", "Chromium";v="127"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'document',
'sec-fetch-mode': 'navigate',
'sec-fetch-site': 'same-origin',
'sec-fetch-user': '?1',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36',
}
import json
import requests
# https://api.bilibili.com/x/player/online/total?aid=530457839&cid=1181074835&bvid=BV1qu411b7EY&ts=57522410
# https://www.bilibili.com/video/BV1qu411b7EY?p=
context = json.loads(info)
print(context)
video_url = context['data']['dash']['video'][0]['baseUrl']
audio_url = context['data']['dash']['audio'][0]['baseUrl']
print(video_url,audio_url)
video_re = requests.get(video_url, headers=headers)
audio_re = requests.get(audio_url, headers=headers)
with open("./video.mp4","wb") as f:
f.write(video_re.content)
with open("./audio.mp4", "wb") as fp:
fp.write(audio_re.content)
【自动化】BB自动化获取视频和音频地址并下载
青龙摄影2024-09-13 13:55
相关推荐
--FGC--6 分钟前
【第2篇】 Python与数据库基础小娄写码7 分钟前
线程池原理m0_630520647 分钟前
Python初识power-辰南1 小时前
机器学习之数据分析及特征工程详细分析过程陌上花开࿈5 小时前
调用第三方接口浊酒南街5 小时前
决策树python实现代码1Aileen_0v05 小时前
【玩转OCR | 腾讯云智能结构化OCR在图像增强与发票识别中的应用实践】FreedomLeo16 小时前
Python机器学习笔记(十三、k均值聚类)星光樱梦6 小时前
32. 线程、进程与协程阿正的梦工坊6 小时前
深入理解 PyTorch 的 view() 函数:以多头注意力机制(Multi-Head Attention)为例 (中英双语)