|
@@ -4,16 +4,45 @@
|
|
|
# @File : GetResponse.py
|
|
|
|
|
|
import requests
|
|
|
+from setting import url,base_url
|
|
|
|
|
|
-headers_bili = {
|
|
|
+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'
|
|
|
+ 'TE': 'Trailers',
|
|
|
+ 'Range': 'bytes=0-',
|
|
|
+ 'Origin': base_url,
|
|
|
+ 'Connection': 'keep-alive',
|
|
|
+ 'DNT': '1',
|
|
|
+ '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(url):
|
|
|
- headers = headers_bili
|
|
|
- response = requests.get(url = url,headers = headers)
|
|
|
- return response
|
|
|
+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)
|
|
|
+# print(a)
|
|
|
+# print(headers_bili_audio)
|