Files
aiData/DouYin/test_playwright.py

45 lines
1.5 KiB
Python
Raw Normal View History

2026-01-20 19:06:36 +08:00
from playwright.sync_api import sync_playwright
import time
def test_playwright():
print("Starting Playwright test...")
try:
with sync_playwright() as p:
print("Launching browser...")
# Try to launch with headless=False but force headless mode via args to use regular chromium
try:
browser = p.chromium.launch(headless=False, args=["--headless=new"])
except Exception as e:
print(f"Failed to launch headless=False with args: {e}")
browser = p.chromium.launch(headless=False)
print("Browser launched.")
page = browser.new_page()
url = "https://www.douyin.com/video/7592981059516583202"
print(f"Navigating to {url}...")
page.goto(url)
print("Page title:", page.title())
# Try to get __ac_signature cookie
cookies = page.context.cookies()
found = False
for cookie in cookies:
if cookie['name'] == '__ac_signature':
print(f"Found cookie: {cookie['name']}")
found = True
break
if not found:
print("Cookie __ac_signature NOT found.")
browser.close()
print("Test finished successfully.")
except Exception as e:
print(f"Playwright failed: {e}")
if __name__ == "__main__":
test_playwright()