Closed AkimfromParis closed 1 year ago
Is there any error/exception that gets thrown? It looks like you might be meaning to use rihanna
instead of "rihanna"
. This could be causing an issue if you're meaning to use a string.
Thank you for your reply. I have no answer. Just an empty list... I tried both methods, TikTokAPI and TikTok in async.
Ps: I don't care about Rihanna's stats. : )
When you call get_stats()
no exception is raised?
When I call get_stats() it raised the following error. Error: It looks like you are using Playwright Sync API inside the asyncio loop. Please use the Async API instead.
I am switching to Async with that...
from tiktokapipy.async_api import AsyncTikTokAPI result = []
async def get_stats(): async with AsyncTikTokAPI() as api: user = await api.user("rihanna") async for video in user.videos: num_comments = video.stats.comment_count num_likes = video.stats.digg_count num_views = video.stats.play_count num_shares = video.stats.share_count result.append((num_comments,num_likes,num_views,num_shares)) return result
When I call the function get_stats. I got an object. get_stats() <coroutine object get_stats at 0x000001D742C5EB40>
Thank you for your help in advance!
You need to call await get_stats()
from within an asyncio loop. I'd suggest looking at an asyncio tutorial if you want to use AsyncTikTokAPI.
Closing as stale
Hello Russell-Newton,
Thank you for your work. I am trying to use TikTokPy for stats. Unfortunately, it doesn't seem to receive any answers. Maybe I am using the function UserStats wrong?! I just want stats of all videos of one user. Thx!
from tiktokapipy.api import TikTokAPI result = []
def get_stats(): with TikTokAPI() as api: user = api.user(rihanna) for video in user.videos: num_comments = video.stats.comment_count num_likes = video.stats.digg_count num_views = video.stats.play_count num_shares = video.stats.share_count result.append(num_comments,num_likes,num_views,num_shares) return result