You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RuntimeError: asyncio.run() cannot be called from a running event loop
Code -
from TikTokApi import TikTokApi
import asyncio
import os
ms_token = os.environ.get("ms_token", None) # get your own ms_token from your cookies on tiktok.com
async def trending_videos():
async with TikTokApi() as api:
await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3)
async for video in api.trending.videos(count=30):
print(video)
print(video.as_dict)
if name == "main":
asyncio.run(trending_videos())
The text was updated successfully, but these errors were encountered:
Getting the following error -
RuntimeError: asyncio.run() cannot be called from a running event loop
Code -
from TikTokApi import TikTokApi
import asyncio
import os
ms_token = os.environ.get("ms_token", None) # get your own ms_token from your cookies on tiktok.com
async def trending_videos():
async with TikTokApi() as api:
await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3)
async for video in api.trending.videos(count=30):
print(video)
print(video.as_dict)
if name == "main":
asyncio.run(trending_videos())
The text was updated successfully, but these errors were encountered: