Open renzaijianghu1 opened 3 months ago
Any news on this? No replies object is found in the comments object, this is the code im using from TikTokApi import TikTokApi import asyncio import os
video_id = 7248300636498890011 ms_token = os.environ.get("ms_token", None) # set your own ms_token
async def get_comments(): async with TikTokApi() as api: await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3) video = api.video(id=video_id) count = 0
async for comment in video.comments(count=30):
print("Comment:")
print(comment)
print(comment.as_dict)
# Fetch and print replies for the comment
async for reply in comment.replies(count=10): # Adjust count as needed
print(" Reply:")
print(reply)
print(reply.as_dict)
if name == "main": asyncio.run(get_comments())
any news?
One parameter to retrieve the replies is wrong. https://github.com/davidteather/TikTok-Api/blob/a4079f0a7ccac4f2a7482272f028849b45387a7d/TikTokApi/api/comment.py#L61
item_id
should be the video id and not the user id.
"item_id": self.as_dict["aweme_id"],
You can workaroud this by adding comment.author.user_id = comment.as_dict["aweme_id"]
right before the comment.replies()
call.
e.g.:
comment.author.user_id = comment.as_dict["aweme_id"]
async for reply in comment.replies(count=10):
print(" Reply:")
print(reply)
print(reply.as_dict)
from TikTokApi import TikTokApi import asyncio import os
video_id = 7379950165601307905 ms_token = os.environ.get("ms_token", None) # set your own ms_token
async def get_comments(): async with TikTokApi() as api: await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3) video = api.video(id=video_id) api.trending count = 0
if name == "main": asyncio.run(get_comments())