Cookies 5

This commit is contained in:
Guillem Hernandez Sola
2026-05-19 11:14:10 +02:00
parent b9e1eb66ad
commit ab32d5b5e4

View File

@@ -33,7 +33,14 @@ import httpx
from atproto import Client from atproto import Client
from dotenv import load_dotenv from dotenv import load_dotenv
from playwright.sync_api import sync_playwright from playwright.sync_api import sync_playwright
# playwright-stealth 1.x uses stealth_sync, 2.x uses Stealth class
try:
from playwright_stealth import stealth_sync from playwright_stealth import stealth_sync
_STEALTH_V2 = False
except ImportError:
from playwright_stealth import Stealth
_STEALTH_V2 = True
# ───────────────────────────────────────────────────────────────────────────── # ─────────────────────────────────────────────────────────────────────────────
# Logging # Logging
@@ -577,6 +584,10 @@ def scrape_tiktoks_via_playwright(handle: str) -> list:
page = context.new_page() page = context.new_page()
# Stealth mode # Stealth mode
# Stealth mode — compatible with both v1.x and v2.x
if _STEALTH_V2:
Stealth().apply_stealth_sync(page)
else:
stealth_sync(page) stealth_sync(page)
# Mask automation signals # Mask automation signals