davidteather / TikTok-Api

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

[BUG] - The page has been closed in Windows 10 #687

Closed Adolescence21 closed 2 years ago

Adolescence21 commented 3 years ago

Describe the bug

Clone the latest source code from repo, build and run docker but get the error on Windows 10

docker build . -t tiktokapi:latest
docker run -v TikTokApi --rm tiktokapi:latest python3 examples/discover.py

The buggy code

The example code: examples/discover.py

Expected behavior

Should return list of trending challenges

Error Trace (if any)

Put the error trace below if there's any error thrown.

$ docker run -v TikTokApi --rm tiktokapi:latest python3 examples/discover.py
Traceback (most recent call last):
  File "examples/discover.py", line 6, in <module>
    trendingMusic = api.discover_music()
  File "/usr/local/lib/python3.8/dist-packages/TikTokApi/tiktok.py", line 1203, in discover_music
    return self.get_data(url=api_url, **kwargs)["body"][2]["exploreList"]
  File "/usr/local/lib/python3.8/dist-packages/TikTokApi/tiktok.py", line 235, in get_data
    verify_fp, device_id, signature = self.browser.sign_url(**kwargs)
  File "/usr/local/lib/python3.8/dist-packages/TikTokApi/browser.py", line 167, in sign_url
    page = context.new_page()
  File "/usr/local/lib/python3.8/dist-packages/playwright/sync_api/_generated.py", line 8817, in new_page       
    self._sync("browser_context.new_page", self._impl_obj.new_page())
  File "/usr/local/lib/python3.8/dist-packages/playwright/_impl/_sync_base.py", line 111, in _sync
    return task.result()
  File "/usr/local/lib/python3.8/dist-packages/playwright/_impl/_browser_context.py", line 181, in new_page     
    return from_channel(await self._channel.send("newPage"))
  File "/usr/local/lib/python3.8/dist-packages/playwright/_impl/_connection.py", line 36, in send
    return await self.inner_send(method, params, False)
  File "/usr/local/lib/python3.8/dist-packages/playwright/_impl/_connection.py", line 54, in inner_send
    result = next(iter(done)).result()
playwright._impl._api_types.Error: Protocol error (Runtime.enable): The page has been closed.

Desktop (please complete the following information):

Additional context

NA

davidteather commented 2 years ago

Please try using V5.0.0 this may solve your problem