mirror of
https://github.com/imgyh/tiktok.git
synced 2025-10-07 20:30:02 +08:00
支持本地生成X-Bogus
由于使用第三方接口必然会产生网络延迟等问题,故支持本地生成X-Bogus 参考项目https://github.com/B1gM8c/tiktok
This commit is contained in:
parent
8f9fe9f1e7
commit
428ab6ff30
@ -51,17 +51,19 @@ class Utils(object):
|
||||
return result
|
||||
|
||||
def getXbogus(self, url, headers=None):
|
||||
# getXbogus算法开源地址https://github.com/B1gM8c/tiktok
|
||||
urls = Urls()
|
||||
query = urllib.parse.urlparse(urls.POST_DETAIL + url).query
|
||||
user_agent = headers.get(
|
||||
'User-Agent') if headers else "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
|
||||
try:
|
||||
response = json.loads(requests.post(
|
||||
url=urls.GET_XB_PATH, data={"param": url}, headers=headers).text)
|
||||
params = response["param"]
|
||||
xb = response["X-Bogus"]
|
||||
xbogus = execjs.compile(open('./X-Bogus.js').read()).call('sign', query, user_agent)
|
||||
params = url + "&X-Bogus=" + xbogus
|
||||
print(params)
|
||||
except Exception as e:
|
||||
print('[ 错误 ]:X-Bogus接口异常, 可能是访问流量高, 接口限流请稍等几分钟再次尝试')
|
||||
print('[ 错误 ]:X-Bogus算法异常')
|
||||
return
|
||||
|
||||
return params # , xb
|
||||
return params
|
||||
|
||||
def str2bool(self, v):
|
||||
if isinstance(v, bool):
|
||||
|
564
X-Bogus.js
Normal file
564
X-Bogus.js
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user