mirror of
https://github.com/imgyh/tiktok.git
synced 2025-05-29 09:39:15 +08:00
fix(tiktok): 修改X-Bogus接口
This commit is contained in:
parent
ef4fa2b4ba
commit
abb9a8e857
@ -145,6 +145,9 @@ python TikTokCommand.py -l https://live.douyin.com/802939216127 -p /path/to/down
|
|||||||
- [ ] 获取分享的音乐链接下的所有作品
|
- [ ] 获取分享的音乐链接下的所有作品
|
||||||
- [ ] 获取热搜榜数据
|
- [ ] 获取热搜榜数据
|
||||||
- [ ] 多主页链接批量下载
|
- [ ] 多主页链接批量下载
|
||||||
|
- [ ] 多线程下载
|
||||||
|
- [ ] 保存数据至数据库
|
||||||
|
- [ ] 制作成接口
|
||||||
|
|
||||||
# 鸣谢
|
# 鸣谢
|
||||||
|
|
||||||
|
24
TikTok.py
24
TikTok.py
@ -32,9 +32,9 @@ class TikTok(object):
|
|||||||
self.utils = Utils()
|
self.utils = Utils()
|
||||||
self.result = Result()
|
self.result = Result()
|
||||||
self.headers = {
|
self.headers = {
|
||||||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36',
|
'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',
|
||||||
'referer':'https://www.douyin.com/',
|
'referer': 'https://www.douyin.com/',
|
||||||
'Cookie': 'msToken=%s;odin_tt=324fb4ea4a89c0c05827e18a1ed9cf9bf8a17f7705fcc793fec935b637867e2a5a9b8168c885554d029919117a18ba69;' % self.utils.generate_random_str(107)
|
'Cookie': 'msToken=%s;odin_tt=324fb4ea4a89c0c05827e18a1ed9cf9bf8a17f7705fcc793fec935b637867e2a5a9b8168c885554d029919117a18ba69;' % self.utils.generate_random_str(107)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ class TikTok(object):
|
|||||||
try:
|
try:
|
||||||
r = requests.get(url=url, headers=self.headers)
|
r = requests.get(url=url, headers=self.headers)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('[ 警告 ]:输入链接有误!\r')
|
print('[ 错误 ]:输入链接有误!\r')
|
||||||
return key_type, key
|
return key_type, key
|
||||||
|
|
||||||
# 抖音把图集更新为note
|
# 抖音把图集更新为note
|
||||||
@ -80,7 +80,7 @@ class TikTok(object):
|
|||||||
key_type = "live"
|
key_type = "live"
|
||||||
|
|
||||||
if key is None or key_type is None:
|
if key is None or key_type is None:
|
||||||
print('[ 警告 ]:输入链接有误!无法获取 id\r')
|
print('[ 错误 ]:输入链接有误!无法获取 id\r')
|
||||||
return key_type, key
|
return key_type, key
|
||||||
print('[ 提示 ]:作品或者用户的 id = %s\r' % key)
|
print('[ 提示 ]:作品或者用户的 id = %s\r' % key)
|
||||||
|
|
||||||
@ -132,9 +132,12 @@ class TikTok(object):
|
|||||||
max_cursor = 0
|
max_cursor = 0
|
||||||
self.awemeList = []
|
self.awemeList = []
|
||||||
|
|
||||||
print("[ 提示 ]:正在获取接口数据请稍后...\r\n")
|
print("[ 提示 ]:正在获取所有作品数据请稍后...\r")
|
||||||
|
print("[ 提示 ]:会进行多次请求,等待时间较长...\r\n")
|
||||||
|
times = 0
|
||||||
while True:
|
while True:
|
||||||
|
times = times + 1
|
||||||
|
print("[ 提示 ]:正在进行第 " + str(times) + " 次请求...\r")
|
||||||
if mode == "post":
|
if mode == "post":
|
||||||
url = self.urls.USER_POST + self.utils.getXbogus(
|
url = self.urls.USER_POST + self.utils.getXbogus(
|
||||||
url=f'sec_user_id={sec_uid}&count={count}&max_cursor={max_cursor}&aid=1128&version_name=23.5.0&device_platform=android&os_version=2333')
|
url=f'sec_user_id={sec_uid}&count={count}&max_cursor={max_cursor}&aid=1128&version_name=23.5.0&device_platform=android&os_version=2333')
|
||||||
@ -168,7 +171,10 @@ class TikTok(object):
|
|||||||
|
|
||||||
# 退出条件
|
# 退出条件
|
||||||
if datadict["has_more"] != 1:
|
if datadict["has_more"] != 1:
|
||||||
|
print("[ 提示 ]:所有作品数据获取完成...\r\n")
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
print("[ 提示 ]:第 " + str(times) + " 次请求成功...\r")
|
||||||
|
|
||||||
return self.awemeList
|
return self.awemeList
|
||||||
|
|
||||||
@ -191,7 +197,7 @@ class TikTok(object):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
if live_json == {} or live_json['status_code'] != 0:
|
if live_json == {} or live_json['status_code'] != 0:
|
||||||
print("[ 警告 ]:接口未返回信息\r")
|
print("[ 错误 ]:接口未返回信息\r")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# 清空字典
|
# 清空字典
|
||||||
@ -284,7 +290,7 @@ class TikTok(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# 使用作品 创建时间+描述 当文件夹
|
# 使用作品 创建时间+描述 当文件夹
|
||||||
file_name = self.utils.replaceStr(awemeDict["create_time"] + awemeDict["desc"])
|
file_name = self.utils.replaceStr(awemeDict["create_time"] + " " + awemeDict["desc"])
|
||||||
aweme_path = os.path.join(savePath, file_name)
|
aweme_path = os.path.join(savePath, file_name)
|
||||||
if not os.path.exists(aweme_path):
|
if not os.path.exists(aweme_path):
|
||||||
os.mkdir(aweme_path)
|
os.mkdir(aweme_path)
|
||||||
|
@ -47,7 +47,7 @@ def getLiveInfo():
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# getAwemeInfo()
|
# getAwemeInfo()
|
||||||
# getUserInfo()
|
# getUserInfo()
|
||||||
getLiveInfo()
|
# getLiveInfo()
|
||||||
pass
|
pass
|
||||||
################################# 测试命令 ######################################################
|
################################# 测试命令 ######################################################
|
||||||
# 视频
|
# 视频
|
||||||
|
@ -55,24 +55,7 @@ class Urls(object):
|
|||||||
self.FOLLOW_FEED = 'https://www.douyin.com/aweme/v1/web/follow/feed/?'
|
self.FOLLOW_FEED = 'https://www.douyin.com/aweme/v1/web/follow/feed/?'
|
||||||
|
|
||||||
# X-Bogus Path
|
# X-Bogus Path
|
||||||
self.GET_XB_PATH = 'http://47.115.200.238/xg/path?url='
|
self.GET_XB_PATH = 'https://tiktok.199933.xyz/xb'
|
||||||
|
|
||||||
# X-Bogus Dict
|
|
||||||
self.GET_XB_DICT = 'http://47.115.200.238/xg/dict/?params='
|
|
||||||
|
|
||||||
# X-Bogus Login
|
|
||||||
self.GET_XB_LOGIN = 'http://47.115.200.238/login'
|
|
||||||
|
|
||||||
# X-Bogus Register
|
|
||||||
self.GET_XB_REGISTER = 'http://47.115.200.238/register'
|
|
||||||
|
|
||||||
# X-Bogus Token
|
|
||||||
self.GET_XB_TOKEN = 'http://47.115.200.238/token'
|
|
||||||
#######################################################################################
|
|
||||||
|
|
||||||
######################################### APP #########################################
|
|
||||||
# X-Gorgon Path
|
|
||||||
self.GET_XG_LOGIN = 'http://47.115.200.238/xog/path?url='
|
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ Change Log :
|
|||||||
|
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
from urllib.parse import urlencode, unquote
|
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
from TikTokUrls import Urls
|
from TikTokUrls import Urls
|
||||||
@ -51,33 +50,17 @@ class Utils(object):
|
|||||||
# 去除前后空格
|
# 去除前后空格
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def getXbogus(self, url, cookie=None, referer="https://www.douyin.com/"):
|
def getXbogus(self, url, headers=None):
|
||||||
urls = Urls()
|
urls = Urls()
|
||||||
headers = {
|
|
||||||
"cookie": cookie,
|
|
||||||
"referer": referer,
|
|
||||||
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
|
|
||||||
}
|
|
||||||
try:
|
try:
|
||||||
if isinstance(url, dict):
|
response = json.loads(requests.post(
|
||||||
params = eval(unquote(url, 'utf-8'))
|
url= urls.GET_XB_PATH, data={"param" : url}, headers=headers).text)
|
||||||
url = urlencode(params, safe="=")
|
|
||||||
response = json.loads(requests.post(
|
|
||||||
urls.GET_XB_DICT + url,
|
|
||||||
headers=headers).text)
|
|
||||||
if isinstance(url, str):
|
|
||||||
url = url.replace('&', '%26')
|
|
||||||
response = json.loads(requests.post(
|
|
||||||
urls.GET_XB_PATH + url,
|
|
||||||
headers=headers).text)
|
|
||||||
else:
|
|
||||||
print('[ 提示 ]:传入的参数有误')
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('[ 错误 ]:%s' % e)
|
print('[ 错误 ]:%s' % e)
|
||||||
|
|
||||||
params = response["result"][0]["paramsencode"]
|
params = response["param"]
|
||||||
xb = response["result"][0]["X-Bogus"]["0"]
|
xb = response["X-Bogus"]
|
||||||
# print('[ 调试 ]:%s' % self.params)
|
|
||||||
return params #, xb
|
return params #, xb
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user