davidteather / TikTok-Api

The Unofficial TikTok API Wrapper In Python
https://davidteather.github.io/TikTok-Api
MIT License
4.8k stars 966 forks source link

run script and no get data #1075

Open andriuy000 opened 1 year ago

andriuy000 commented 1 year ago
from TikTokApi import TikTokApi
import asyncio
import os

ms_token = os.environ.get("nABaDGdJ97QRP9PDZxqx5GWrA-dKBRYsvZJ5kCUWsGel4-DnBKr-fRFM0zHdPXU8ua3BU15aX4j3LiVchi6tNchsjEhm-RbQ5gOsMQr4slb1T2mGLTey1WSGPLZY5iP4eLaAc1gJGgXDYGgirQ==", None)  # set your own ms_token

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())

output Process finished with exit code 0

Arroquw commented 11 months ago

Having the same issue, I run the script, nothing comes out.

GusttavoMartins commented 11 months ago

Did you manage to solve it? I have the same problem

andriuy000 commented 11 months ago

no

Hkllopp commented 5 months ago

It seems to be a problem with the trending generator (api.trending.videos()) that returns an empty generator. Had the same problem, but tried another example (specifically video_example.py) and it worked.