Browser4 icon indicating copy to clipboard operation
Browser4 copied to clipboard

调查 Patchright 相对 Playwright 做了哪些改进

Open platonai opened this issue 7 months ago • 0 comments

调查 Patchright 相对 Playwright 做了哪些改进。

🕵️‍♂️ Patchright – Stealth-Enhanced Playwright for Web Automation

Patchright is a customized fork of Playwright, specifically tailored for web automation and crawling tasks. It focuses on bypassing bot detection systems like Cloudflare, Akamai, Datadome, and more.


🚀 Key Features

  • Anti-Bot Detection: Patchright includes deep patches to evade browser automation fingerprinting mechanisms widely used by modern anti-bot systems.

  • Drop-in Replacement: Fully compatible with Playwright. Just replace:

    from playwright.sync_api import sync_playwright
    # → becomes
    from patchright.sync_api import sync_playwright
    
  • Enhanced Stealth:

    • Patches Runtime.enable to prevent automation exposure
    • Fixes detection vectors in Console.enable
    • Optimizes browser launch arguments to avoid common flags
    • Supports interaction with closed Shadow DOM
    • No breaking changes to original Playwright API

🧰 Compatibility

  • ✅ Supports Windows, macOS, and Linux
  • ✅ Requires Python 3.9+
  • ✅ Compatible with Playwright test runners and browser binaries

📦 Installation

pip install patchright

📄 Example

from patchright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(headless=False)
    page = browser.new_page()
    page.goto("https://example.com")
    print(page.title())
    browser.close()

platonai avatar May 11 '25 13:05 platonai