Cookies 5
This commit is contained in:
@@ -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
|
||||||
from playwright_stealth import stealth_sync
|
# playwright-stealth 1.x uses stealth_sync, 2.x uses Stealth class
|
||||||
|
try:
|
||||||
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user