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
相关推荐
研一计算机小白一枚18 分钟前
Which Tasks Should Be Learned Together in Multi-task Learning? 译文Eric.Lee202132 分钟前
数据集-目标检测系列- 蘑菇 检测数据集 mushroom >> DataBall2401_8532757340 分钟前
Java IO 基础知识总结下运维笑谈42 分钟前
【python系列】python数据类型之元组我想睡到自然醒₍˄·͈༝·͈˄*₎◞ ̑1 小时前
【Android】View的解析—滑动篇诸神黄昏EX1 小时前
Android 常用命令和工具解析之内存相关叫我:松哥1 小时前
基于python的长津湖评论数据分析与可视化,使用是svm情感分析建模萧鼎1 小时前
轻松解析 PDF 文档:深入了解 Python 的 pdfplumber 库有请小发菜1 小时前
Python 编程开发(01):Bash 命令行基本操作dreamsever1 小时前
Glide源码学习