#!/usr/bin/env python3
"""调试：截图看 DeepSeek 页面实际内容"""
import asyncio
from playwright.async_api import async_playwright

async def main():
    async with async_playwright() as p:
        browser = await p.chromium.launch(
            headless=True,
            args=["--no-sandbox", "--disable-gpu", "--disable-dev-shm-usage",
                  "--disable-setuid-sandbox", "--no-first-run", "--no-zygote",
                  "--single-process"],
        )
        context = await browser.new_context(
            user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
            viewport={"width": 1920, "height": 1080},
            locale="zh-CN",
        )
        page = await context.new_page()

        print("[1] 访问首页...")
        await page.goto("https://chat.deepseek.com/", wait_until="networkidle", timeout=60000)
        await asyncio.sleep(3)
        await page.screenshot(path="/tmp/deepseek_home.png")
        title = await page.title()
        content = await page.content()
        print(f"  title={title}")
        print(f"  content[:500]={content[:500]}")

        print("[2] 访问登录页...")
        await page.goto("https://chat.deepseek.com/sign_in", wait_until="networkidle", timeout=30000)
        await asyncio.sleep(3)
        await page.screenshot(path="/tmp/deepseek_login.png")
        title = await page.title()
        content = await page.content()
        print(f"  title={title}")
        print(f"  content[:500]={content[:500]}")

        # 找所有 input
        inputs = await page.locator('input').all()
        print(f"  inputs found: {len(inputs)}")
        for i, inp in enumerate(inputs):
            tp = await inp.get_attribute('type') or 'text'
            ph = await inp.get_attribute('placeholder') or ''
            print(f"    input[{i}]: type={tp} placeholder={ph}")

        await browser.close()

asyncio.run(main())