error retrieving the user data from tiktok

464 views Asked by At

I want to extract the user stats from unofficial tiktokapi (https://github.com/davidteather/TikTok-Api) the code i used is below

from TikTokApi.tiktok import TikTokApi
with TikTokApi() as api: # .get_instance no longer exists
    for trending_video in api.trending.videos():
     user_stats = trending_video.author.info_full['stats']
     if user_stats['followerCount'] >= 10000:
        print(user_stats)

but i keep on getting this error -

RuntimeError: This event loop is already running

Task exception was never retrieved
future: <Task finished name='Task-5' coro=<Connection.run() done, defined at C:\Users\siddh\anaconda3\lib\site-packages\playwright\_impl\_connection.py:240> exception=NotImplementedError()>
Traceback (most recent call last):
  File "C:\Users\siddh\anaconda3\lib\site-packages\playwright\_impl\_connection.py", line 247, in run
    await self._transport.connect()
  File "C:\Users\siddh\anaconda3\lib\site-packages\playwright\_impl\_transport.py", line 132, in connect
    raise exc
  File "C:\Users\siddh\anaconda3\lib\site-packages\playwright\_impl\_transport.py", line 120, in connect
    self._proc = await asyncio.create_subprocess_exec(
  File "C:\Users\siddh\anaconda3\lib\asyncio\subprocess.py", line 236, in create_subprocess_exec
    transport, protocol = await loop.subprocess_exec(
  File "C:\Users\siddh\anaconda3\lib\asyncio\base_events.py", line 1676, in subprocess_exec
    transport = await self._make_subprocess_transport(
  File "C:\Users\siddh\anaconda3\lib\asyncio\base_events.py", line 498, in _make_subprocess_transport
    raise NotImplementedError
NotImplementedError

i tried using asyncio but the error keeps on coming any fixes to this

1

There are 1 answers

0
Nexif On

please note that if you're running the code in Jupyter Notebook - it won't work. As the documentation of this library says:

Note: Jupyter (ipynb) only works on linux

Paste your code into .py file and try running it as a Python script instead with:

python tiktok_script.py