mirror of
https://github.com/imgyh/tiktok.git
synced 2025-04-06 08:15:46 +08:00
fix(live): 统一直播获取的header, 直播接口添加X-Bogus
This commit is contained in:
parent
8a01e681b5
commit
197d12627d
10
TikTok.py
10
TikTok.py
@ -192,15 +192,11 @@ class TikTok(object):
|
|||||||
|
|
||||||
# web_rid = live_url.replace('https://live.douyin.com/', '')
|
# 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)
|
live_api = self.urls.LIVE + self.utils.getXbogus(
|
||||||
|
url=f'aid=6383&device_platform=web&web_rid={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'
|
|
||||||
}
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.get(live_api, headers=headers)
|
response = requests.get(live_api, headers=self.headers)
|
||||||
live_json = json.loads(response.text)
|
live_json = json.loads(response.text)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("[ 错误 ]:接口未返回数据, 请检查后重新运行!\r")
|
print("[ 错误 ]:接口未返回数据, 请检查后重新运行!\r")
|
||||||
|
@ -68,6 +68,9 @@ class Urls(object):
|
|||||||
# 需要 ttwid
|
# 需要 ttwid
|
||||||
self.USER_MIX_LIST = 'https://www.douyin.com/aweme/v1/web/mix/list/?'
|
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
|
# X-Bogus Path
|
||||||
# 60 秒内,请求同一URI累计超过 600 次,封锁IP 300 秒
|
# 60 秒内,请求同一URI累计超过 600 次,封锁IP 300 秒
|
||||||
self.GET_XB_PATH = 'https://tiktok.199933.xyz/xb'
|
self.GET_XB_PATH = 'https://tiktok.199933.xyz/xb'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user