TikTok-Api icon indicating copy to clipboard operation
TikTok-Api copied to clipboard

Just Want Text

Open TebuKanaeru opened this issue 4 months ago • 0 comments

From the script below, can we only get text/comments from the user?

from TikTokApi import TikTokApi import asyncio import os

video_id = 7331767529976745234 ms_token = os.environ.get("ms_token", None) # set your own ms_token

context_options = { 'viewport' : { 'width': 1280, 'height': 1024 }, 'user_agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36' }

async def get_comments(): async with TikTokApi() as api: await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3, headless=False) video = api.video(id=video_id) count = 0 async for comment in video.comments(count=100): print(comment) print(comment.as_dict)

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

TebuKanaeru avatar Feb 12 '24 01:02 TebuKanaeru