# 用 PowerShell Start-Process 启动 Chrome 调试模式
import subprocess

chrome = r"C:\Program Files\Google\Chrome\Application\chrome.exe"
args = [
    "--remote-debugging-port=9223",
    "--user-data-dir=C:\\ChromeDebug_BJH",
    "--no-first-run",
    "--no-default-browser-check",
    "--new-window",
    "https://baijiahao.baidu.com"
]

cmd = ["powershell", "-Command",
       f"Start-Process -FilePath '{chrome}' -ArgumentList '{' '.join(args)}' -PassThru | Select-Object -ExpandProperty Id"]

print("Starting Chrome...")
result = subprocess.run(cmd, capture_output=True, text=True)
print(result.stdout)
print(result.stderr)
