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
I made a modification to the code and added a "domcontentloaded" in tiktok.__create_session Something interesting happened to me when I run the application with headless=False and channel=chrome, it works, but when I pass headless=True and channel=chrome it starts to fail and gives "TikTok returned an empty response" in the same way I tried to keep headless=False with a virtual Display(pyvirtualdisplay and xvfb-run in docker), but it still detects that I do not have the active TikTok screen
To reply, use get videos and get comments as shown in the examples
playwright=1.52.0
python=3.11.13
api = TikTokApi()
await api.create_sessions(num_sessions=2, sleep_after=2, cookies=cookies,
proxies=proxy, context_options={"viewport": {"width": 1694, "height": 875},
"user_agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36",
})
await page.goto(url)
await page.goto(url) # hack: tiktok blocks first request not sure why, likely bot detection
# by doing this, we are simulate scroll event using mouse to `avoid` bot detection
x, y = random.randint(0, 50), random.randint(0, 50)
a, b = random.randint(1, 50), random.randint(100, 200)
await page.mouse.move(x, y)
# await page.wait_for_load_state("networkidle")
try:
await page.wait_for_load_state("networkidle")
except Exception as e:
self.logger.warning(f"No se alcanzó 'networkidle': {e}, usando 'domcontentloaded'")
await page.wait_for_load_state("domcontentloaded", timeout=5000)
await page.mouse.move(a, b)
In case it happened to someone, because it seems that TikTok has it well controlled when it runs without the screen even when using a virtual one like pyvirtualdisplay or xvfb-run
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I made a modification to the code and added a "domcontentloaded" in tiktok.__create_session Something interesting happened to me when I run the application with headless=False and channel=chrome, it works, but when I pass headless=True and channel=chrome it starts to fail and gives "TikTok returned an empty response" in the same way I tried to keep headless=False with a virtual Display(pyvirtualdisplay and xvfb-run in docker), but it still detects that I do not have the active TikTok screen
To reply, use get videos and get comments as shown in the examples
playwright=1.52.0
python=3.11.13
In case it happened to someone, because it seems that TikTok has it well controlled when it runs without the screen even when using a virtual one like pyvirtualdisplay or xvfb-run
Beta Was this translation helpful? Give feedback.
All reactions