Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: tiktok returned invalid reponse by bot detection (#1197)
Browse files Browse the repository at this point in the history
Co-authored-by: David Teather <[email protected]>
arhen and davidteather authored Jan 21, 2025

Verified

This commit was signed with the committer’s verified signature.
larskuhtz Lars Kuhtz
1 parent ffdca23 commit ccb0b1a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion TikTokApi/tiktok.py
Original file line number Diff line number Diff line change
@@ -183,7 +183,15 @@ def handle_request(request):
page.set_default_navigation_timeout(timeout)

await page.goto(url)
await page.goto(url) # hack: tiktok blocks first request not sure why
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
await page.wait_for_load_state("networkidle")
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.mouse.move(a, b)

session = TikTokPlaywrightSession(
context,

0 comments on commit ccb0b1a

Please sign in to comment.