Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] TikTok的用户详情接口是不是不能用了 #780

Closed
4 tasks done
ifdandy opened this issue Jan 15, 2025 · 12 comments
Closed
4 tasks done

[BUG] TikTok的用户详情接口是不是不能用了 #780

ifdandy opened this issue Jan 15, 2025 · 12 comments
Labels
故障(bug) 代码问题导致的错误(Bugs caused by code problems)

Comments

@ifdandy
Copy link

ifdandy commented Jan 15, 2025

  • 我查看了 文档 以及 已关闭的问题 以寻找可能的解决方案。

  • 我在 常见的问题与解决办法 中找不到我的问题。

  • 你的问题是公开的,请注意删除个人敏感内容再上传

  • 不按照模板填写的问题将不会得到优先的处理。

  • 如果错误问题是可视化的,请在屏幕截图贴截图。如果你是开发者请在错误重现提供一个最小的代码示例来演示该问题。

  • 相同的问题将会被标记重复(duplicate),如果你的问题被标记为已确认(confirmed)则会在后续的推送中修复,请时刻留意。

  • 退订邮件提醒请点击邮件的底部unsubscribe

详细描述错误
WARNING 第 5 次请求响应内容为空, 状态码: 200,
URL:https://www.tiktok.com/api/user/detail/?WebIdLastTime=1736927933&a
id=1988&app_language=zh-Hans&app_name=tiktok_web&browser_language=zh-C
N&browser_name=Mozilla&browser_online=true&browser_platform=Win32&brow
ser_version=5.0%20%28Windows%20NT%2010.0%3B%20Win64%3B%20x64%29%20Appl
eWebKit%2F537.36%20%28KHTML%2C%20like%20Gecko%29%20Chrome%2F130.0.0.0%
20Safari%2F537.36&channel=tiktok_web&cookie_enabled=true&device_id=737
7772863376426514&device_platform=web_pc&focus_state=true&from_page=use
r&history_len=4&is_fullscreen=false&is_page_visible=true&language=zh-H
ans&os=windows&priority_region=&referer=&region=SG&screen_height=1080&
screen_width=1920&webcast_language=zh-Hans&tz_name=Asia%2FHong_Kong&ms
Token=AkfxFAznNInHg16hpMYSzAMHGC64lspDg4jJ7LHyf5MjIJFZksjKdP9Uhrv6q4zz
v3oBVum7OduHt2BlPrF5XhZSRhE220CevB23YMbXyn9YR0H2fMmv6YzI-7uzazPmDW42dU
rG8p2DAsT303HA&secUid=MS4wLjABAAAA9ESVs2KFuSmRZAIX29xWJ5MTFl3r0bmWc7-R
oVgLnwAg3KEOkRZaZ6ENmxumgOT1&uniqueId=&X-Bogus=DFSzswVYqEUANjactp/mPM9
WX7nS

我通过执行这个代码下载博主所有视频,但是一直卡在这个接口返回为空
await TiktokHandler(kwargs).handle_user_post()

我自行确认各项配置没有问题,可以正常请求视频列表,ApiPost等工具测试也都是正常的,只有这个接口没有任何返回

系统平台

单击展开 Q:你在哪个平台(Win/Linux/Mac)上运行?你使用的是什么浏览器?你使用的是什么终端软件?你使用的F2是什么版本?

A:

  • 操作系统: [e.g. Win11 ]
  • 浏览器 [e.g. Chrome]
  • 终端 [e.g. Python Code]
  • F2版本 [e.g. 0.0.1.7]

错误重现
Debug模式无任何异常信息

预期行为
简明扼要地描述期望发生的事情。

屏幕截图
请添加截图以帮助解释你的问题。

日志文件
请添加调试日志文件以帮助解释你的问题。

其他
如有,可以添加有关问题的其他信息。

@ifdandy ifdandy added the 故障(bug) 代码问题导致的错误(Bugs caused by code problems) label Jan 15, 2025
@Johnserf-Seed
Copy link
Owner

可以用

@Johnserf-Seed
Copy link
Owner

02de82c6554eb73ac9789e5bb55df28

@Johnserf-Seed
Copy link
Owner

@ifdandy
Copy link
Author

ifdandy commented Jan 15, 2025

@Johnserf-Seed 我这边不管怎么配置都拿不到数据

image

@Johnserf-Seed
Copy link
Owner

@Johnserf-Seed 我这边不管怎么配置都拿不到数据

image

Johnserf-Seed/f2#79
Johnserf-Seed/f2#154

@Johnserf-Seed
Copy link
Owner

配置绑定的设备id

@ifdandy
Copy link
Author

ifdandy commented Jan 15, 2025

我没看懂device_id是怎么绑定的,自动生成的yaml文件,没有这个字段,我代码里面这么写:
`async def main():
device_ids = await DeviceIdManager.gen_device_id(full_cookie=True)
print(device_ids)
kwargs = {
"headers": {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
"Referer": "https://www.tiktok.com/@tatemcrae",
},
# "proxies": {"http://": None, "https://": None},
"timeout": 10,
# TikTok 视频列表
'cookie': 'tiktok_webapp_theme=light; perf_fe.........; '+device_ids['cookie'],
'path': 'Download',
'desc': True,
'cover': True,
'folderize': True,
"naming": "{uid}-{create}",
'url': 'https://www.tiktok.com/@tatemcrae', # 下载作品
"mode": "post", # post、live
"device_id": device_ids['deviceId']
}
user = await TiktokHandler(kwargs).fetch_user_profile(uniqueId="tatemcrae")
print(user)

if name == "main":
asyncio.run(main())
`

运行还是绑定不了,而且生成的请求里面已经带了一个不同的device_id。很迷惑

@Johnserf-Seed
Copy link
Owner

我没看懂device_id是怎么绑定的,自动生成的yaml文件,没有这个字段,我代码里面这么写: `async def main(): device_ids = await DeviceIdManager.gen_device_id(full_cookie=True) print(device_ids) kwargs = { "headers": { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36", "Referer": "https://www.tiktok.com/@tatemcrae", }, # "proxies": {"http://": None, "https://": None}, "timeout": 10, # TikTok 视频列表 'cookie': 'tiktok_webapp_theme=light; perf_fe.........; '+device_ids['cookie'], 'path': 'Download', 'desc': True, 'cover': True, 'folderize': True, "naming": "{uid}-{create}", 'url': 'https://www.tiktok.com/@tatemcrae', # 下载作品 "mode": "post", # post、live "device_id": device_ids['deviceId'] } user = await TiktokHandler(kwargs).fetch_user_profile(uniqueId="tatemcrae") print(user)

if name == "main": asyncio.run(main()) `

运行还是绑定不了,而且生成的请求里面已经带了一个不同的device_id。很迷惑

image
要保持一致,因为设备id和cookie以及ua都是绑定状态,一个更新了都需要更新一遍,设备id配置在conf.yaml中,更多的代码片段参考我前面发的2个链接

Copy link

dosubot bot commented Jan 15, 2025

@ifdandy 你好,欢迎来到这里!我是一个可以帮助你解决 bug、回答问题,并帮助你成为贡献者的机器人。我会尽力帮助你,让你在等待人类维护者的过程中感到更轻松。

I found a similar unsolved discussion that might be relevant to your issue: 请求状态码200但无返回数据, which was last updated on March 2, 2024 [1].

For the issue of receiving an empty response with a status code 200, it is often related to cookie problems. The suggested solution is to try using a different account that hasn't been restricted [2].

Additionally, ensure that your configuration parameters are correct. The TiktokHandler requires specific configurations, such as a valid msToken, ttwid, and odin_tt, among others. Make sure these are correctly set in your configuration file [3].

If the problem persists, consider checking the known issues with the TikTok API integration in the F2 library, such as cookie issues or API rate limits [4].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@ifdandy
Copy link
Author

ifdandy commented Jan 15, 2025

大概了解了,我这边没有指定conf.yaml,我再看看。不过我没明白,既然device_id会引起tiktok的使用困难,为啥不直接封装到业务流程里面呢,还需要暴露出来我们自己debug

@ifdandy
Copy link
Author

ifdandy commented Jan 15, 2025

@Johnserf-Seed 大佬,我还是没搞定,我使用device_id替换了conf.yaml里面的
device: id: "7460008423353271854" platform: web_pc
这个也修改了:
ttwid: url: https://www.tiktok.com/ttwid/check/ data: '{"aid":1988,"service":"www.tiktok.com","union":false,"unionHost":"","needFid":false,"fid":"","migrate_priority":0}' cookie: "ttwid=1%7Cc3AYgSx1uPLTtR_9xAcluuySQ4NAz0KfcPkp6lQdKT0%7C1736933061%7C83a3a50260ae3e6b016718d7cc58dfd253ec37602abbdfc877253c6480f01133"

image

这里也修改了,还是不行啊

WARNING 第 1 次请求响应内容为空, 状态码: 200, URL:https://www.tiktok.com/api/user/detail/?WebIdLastTime=1736933347&a id=1988&app_language=zh-Hans&app_name=tiktok_web&browser_language=zh-C N&browser_name=Mozilla&browser_online=true&browser_platform=Win32&brow ser_version=5.0%20%28Windows%20NT%2010.0%3B%20Win64%3B%20x64%29%20Appl eWebKit%2F537.36%20%28KHTML%2C%20like%20Gecko%29%20Chrome%2F130.0.0.0% 20Safari%2F537.36&channel=tiktok_web&cookie_enabled=true&device_id=746 0008423353271854&device_platform=web_pc&focus_state=true&from_page=use r&history_len=4&is_fullscreen=false&is_page_visible=true&language=zh-H ans&os=windows&priority_region=&referer=&region=SG&screen_height=1080& screen_width=1920&webcast_language=zh-Hans&tz_name=Asia%2FHong_Kong&ms Token=xwZ0_rUQ-jNRk_GEAxw-seLD_Qu-D3nRKGRLHf-55H8W6F86rRyTNMFfeFWfWI8c WNMDiNOeyvW7BYekYKCPHIu_tPNhSYXwtKh-aVUMpr8Qxw2UbKjvicY8KX9BeZnaJzV7gt ZGwGPFNkiRglSG&secUid=MS4wLjABAAAAQhcYf_TjRKUku-aF8oqngAfzrYksgGLRz8CK MciBFdfR54HQu3qGs-WoJ-KO7hO8&uniqueId=&X-Bogus=DFSzswVYYbtANJXJtp/a7l9 WX7JV

@Johnserf-Seed
Copy link
Owner

用登录的ck,再配置上对应的设备id,ua与配置文件中的保持一致,代理可用。满足上述要求就ok了。
Johnserf-Seed/f2#154
Johnserf-Seed/f2#79

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
故障(bug) 代码问题导致的错误(Bugs caused by code problems)
Projects
None yet
Development

No branches or pull requests

2 participants