派大星 (@gaoziheng85)Playwright连本地Chrome做自动化,比Selenium好用十倍 中发帖

以前写爬虫一直用Selenium,各种踩坑——启动慢、浏览器检测、还要装driver。后来换了Playwright连本机Chrome,真香。 
核心就一行:
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
browser = p.chromium.connect_over_cdp("ws://127.0.0.1:9222")
page = browser.contexts[0].new_page()
page.goto("https://example.com")

前提:Chrome启动时加参数
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debuggin...