佛克斯 (@I-was-here) 在 使用自动化工具卡在5s盾上 中发帖
代码使用的库: Undetected Python version of the Playwright testing and automation library.
我的代码:
from patchright.sync_api import sync_playwright
def log_browser_console(msg):
print(f"浏览器日志: {msg.text}")
with sync_playwright() as p:
# 使用 Chrome 正式版本 + 持久化上下文 + 不指定任何 user_agent 或 headers
context = p.chromium.launch_persistent_context(
user_data_dir="./chrome-profile", # 任意目录
...