From 197d12627d855f3353dba3fd68f0b308593f62e8 Mon Sep 17 00:00:00 2001 From: imgyh <1974355683@qq.com> Date: Thu, 23 Feb 2023 10:50:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(live):=20=E7=BB=9F=E4=B8=80=E7=9B=B4?= =?UTF-8?q?=E6=92=AD=E8=8E=B7=E5=8F=96=E7=9A=84header,=20=E7=9B=B4?= =?UTF-8?q?=E6=92=AD=E6=8E=A5=E5=8F=A3=E6=B7=BB=E5=8A=A0X-Bogus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TikTok.py | 10 +++------- TikTokUrls.py | 3 +++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/TikTok.py b/TikTok.py index 98add39..147c1a2 100644 --- a/TikTok.py +++ b/TikTok.py @@ -192,15 +192,11 @@ class TikTok(object): # web_rid = live_url.replace('https://live.douyin.com/', '') - live_api = 'https://live.douyin.com/webcast/room/web/enter/?aid=6383&device_platform=web&web_rid=%s' % (web_rid) - - headers = { - 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36', - 'cookie' : '__ac_nonce=063f2f2fe002b0c1cf5a3; ttwid=1|_P0qI1eym6Of_Wz2s3FhDRThixb46o2hSYqHFIcdaHM|1676866302|3dd715d4512ff13abbd1aaedc19257b8bfe55b2bbbcad6a95de237776729ba54' - } + live_api = self.urls.LIVE + self.utils.getXbogus( + url=f'aid=6383&device_platform=web&web_rid={web_rid}') try: - response = requests.get(live_api, headers=headers) + response = requests.get(live_api, headers=self.headers) live_json = json.loads(response.text) except Exception as e: print("[ 错误 ]:接口未返回数据, 请检查后重新运行!\r") diff --git a/TikTokUrls.py b/TikTokUrls.py index 38efe75..59ed1aa 100644 --- a/TikTokUrls.py +++ b/TikTokUrls.py @@ -68,6 +68,9 @@ class Urls(object): # 需要 ttwid self.USER_MIX_LIST = 'https://www.douyin.com/aweme/v1/web/mix/list/?' + # 直播 + self.LIVE = 'https://live.douyin.com/webcast/room/web/enter/?' + # X-Bogus Path # 60 秒内,请求同一URI累计超过 600 次,封锁IP 300 秒 self.GET_XB_PATH = 'https://tiktok.199933.xyz/xb'