|
@@ -3,44 +3,54 @@
|
|
|
# @Time : 2024/9/13 15:03
|
|
|
# @File : GetResponse.py
|
|
|
|
|
|
+from .setting import *
|
|
|
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',
|
|
|
+# //视频音频请求头//
|
|
|
+headers_bili_av = {
|
|
|
+ 'Accept': '*/*',
|
|
|
+ 'Accept-Language': 'zh,en-US;q=0.7,en;q=0.3',
|
|
|
+ 'Accept-Encoding': 'gzip, deflate, br',
|
|
|
'TE': 'Trailers',
|
|
|
+ 'Range': 'bytes=0-',
|
|
|
+ 'Origin': 'https://www.bilibili.com',
|
|
|
+ 'Connection': 'keep-alive',
|
|
|
+ 'DNT': '1',
|
|
|
+ 'referer': 'https://www.bilibili.com',
|
|
|
+ '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'
|
|
|
+}
|
|
|
+# //准许请求头//
|
|
|
+headers_bili_ref = {
|
|
|
+ 'Host': 'cn-gdgz4-cmcc-v-10.bilivideo.com',
|
|
|
+ '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',
|
|
|
+ 'Accept': '*/*',
|
|
|
+ 'Accept-Language': 'zh,en-US;q=0.7,en;q=0.3',
|
|
|
+ 'Accept-Encoding': 'gzip, deflate, br',
|
|
|
'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',
|
|
|
+ 'Cache-Control': 'max-age=0'
|
|
|
+}
|
|
|
+
|
|
|
+headers = {
|
|
|
+ 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
|
|
|
+ 'Accept-Language': 'zh,en-US;q=0.7,en;q=0.3',
|
|
|
+ 'Accept-Encoding': 'gzip, deflate',
|
|
|
+ 'Connection': 'keep-alive',
|
|
|
'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
|
|
|
+video_json = {
|
|
|
|
|
|
-def GetResponse_video(url):
|
|
|
- response_video = requests.get(url = url,headers = headers_bili_video)
|
|
|
- return response_video
|
|
|
+}
|
|
|
|
|
|
-# 测试代码
|
|
|
-if __name__ == '__main__':
|
|
|
+def GetResponse_AV():
|
|
|
+ response_audio = requests.get(url = url,headers = headers_bili_av)
|
|
|
+ return response_audio
|
|
|
|
|
|
- a = GetResponse_audio(url)
|
|
|
- b = GetResponse_video(url)
|
|
|
- print(a)
|
|
|
- print(b)
|
|
|
+# 检查
|
|
|
+if __name__ == '__main__':
|
|
|
+ print(GetResponse_AV())
|