# -*- coding: utf-8 -*- # @Author : ChenZhaoyuchen # @Time : 2024/9/13 15:03 # @File : GetResponse.py import requests from setting import url,base_url headers_bili_video = { '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 - encoding': 'gzip, deflate', 'accept - language': 'zh - CN, zh;q = 0.9, en;q = 0.8, en - GB;q = 0.7, en - US;q = 0.6', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0', 'Referer': 'https://www.bilibili.com/?spm_id_from=333.337.0.0' } headers_bili_audio = { '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 - encoding': 'gzip, deflate', 'accept - language': 'zh - CN, zh;q = 0.9, en;q = 0.8, en - GB;q = 0.7, en - US;q = 0.6', 'TE': 'Trailers', 'Access-Control-Request-Method': 'GET', 'Access-Control-Request-Headers': 'range', 'Referer': url, 'Origin': base_url, 'DNT': '1', 'Connection': 'keep-alive', 'Cache-Control': 'max-age=0', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0' } def GetResponse_audio(url): response_audio = requests.get(url = url,headers = headers_bili_audio) return response_audio def GetResponse_video(url): response_video = requests.get(url = url,headers = headers_bili_video) return response_video # 测试代码 if __name__ == '__main__': a = GetResponse_audio(url) b = GetResponse_video(url) print(a) print(b)