zhangliang 3 mesi fa
parent
commit
a38856fbb0
1 ha cambiato i file con 3 aggiunte e 1 eliminazioni
  1. 3 1
      cookie_generator.py

+ 3 - 1
cookie_generator.py

@@ -7,6 +7,7 @@ from loguru import logger
 from playwright.sync_api import sync_playwright
 from config import BROWSER_CONFIG
 from dy_cookie_manager import DouyinCookieManager
+from playwright_stealth import stealth
 
 
 class CookieGenerator:
@@ -45,12 +46,13 @@ class CookieGenerator:
                     viewport={"width": 1920, "height": 1080}
                 )
                 page = context.new_page()
+                stealth_config = stealth.Stealth()
 
                 # 反检测
                 page.add_init_script("""
                     Object.defineProperty(navigator, 'webdriver', { get: () => undefined });
                 """)
-
+                stealth_config.apply_stealth_sync(page)
                 # 访问抖音
                 page.goto("https://www.douyin.com", timeout=30000, wait_until="domcontentloaded")
                 time.sleep(5)