TikTok-Api
TikTok-Api copied to clipboard
[FEATURE_REQUEST] - Is there any way to get likes count for each video
Is there any way to get likes count for each video?
hey @gridikono We can already do that, I wrote this little function so you should be able to do so
def tiktokUrlBuilder(username, videoID):
return f"https://www.tiktok.com/@{username}/video/{videoID}"
async def getUserVideos(username):
videos = []
async with TikTokApi() as api:
await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3, headless=False, override_browser_args=["--incognito"])
user = api.user(username)
# user_data = await user.info()
async for video in user.videos(count=10):
videos.append(video.as_dict)
return videos
async def getVideoInfo(username, video):
videoUrl = tiktokUrlBuilder(username, video['id'])
async with TikTokApi() as api:
await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3)
video_object = api.video(url=videoUrl)
videoInfo = await video_object.info()
return videoInfo
Hi @shinitiandrei,
Thanks for posting the code, just wondering how you found out to write "headless=False", it looks like making headless=True currently causes an error, I'm not too sure how come though?
This can be seen from the PyTest modules underneath the tests\ directory (about half of them are currently failing straight out of the box)
Hi @shinitiandrei,
Thanks for posting the code, just wondering how you found out to write "headless=False", it looks like making headless=True currently causes an error, I'm not too sure how come though?
This can be seen from the PyTest modules underneath the tests\ directory (about half of them are currently failing straight out of the box)
Hey @M-Minkov Follow this thread, I've posted my answer that at the bottom how I found the fix: https://github.com/davidteather/TikTok-Api/issues/1074