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,url,音频,headers,sec,自动化,video,audio,page From: https://blog.csdn.net/lfsysc/article/details/142070349