{"library":"patchright","title":"Patchright","description":"Patchright is an undetected Python version of the Playwright testing and automation library (version 1.58.2). It serves as a drop-in replacement for Playwright, specifically designed to bypass modern anti-bot detection systems by patching Chrome DevTools Protocol (CDP) leaks and browser fingerprinting issues. The library is actively maintained and receives updates to combat evolving detection techniques.","language":"python","status":"active","last_verified":"Thu May 14","install":{"commands":["pip install patchright"],"cli":{"name":"patchright","version":"Version 1.59.1"}},"imports":["from patchright.sync_api import sync_playwright","from patchright.async_api import async_playwright"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nimport asyncio\nfrom patchright.sync_api import sync_playwright\n\ndef run_sync_example():\n    with sync_playwright() as p:\n        # Recommended configuration for maximum undetectability:\n        # Use launch_persistent_context with channel='chrome' and headless=False\n        # viewport=null (or no_viewport=True) prevents setting a fixed viewport, aiding stealth.\n        # user_data_dir is crucial for persisting cookies/session info if solving captchas manually.\n        user_data_dir = os.environ.get('PATCHRIGHT_USER_DATA_DIR', '/tmp/patchright_profile')\n        browser = p.chromium.launch_persistent_context(\n            user_data_dir=user_data_dir,\n            channel=\"chrome\",\n            headless=False,\n            viewport=None, # equivalent to no_viewport=True\n            # Do NOT add custom browser headers or user_agent here, Patchright handles it.\n        )\n        page = browser.new_page()\n        try:\n            print(f\"Navigating to example.com with {p.chromium.name}...\")\n            page.goto(\"https://example.com\")\n            print(f\"Page title: {page.title()}\")\n            # Example interaction: get text from an element\n            text = page.locator('h1').inner_text()\n            print(f\"H1 text: {text}\")\n            page.screenshot(path=f\"example-{p.chromium.name}.png\")\n            print(\"Screenshot saved.\")\n        finally:\n            browser.close()\n            print(\"Browser closed.\")\n\nasync def run_async_example():\n    async with async_playwright() as p:\n        user_data_dir = os.environ.get('PATCHRIGHT_USER_DATA_DIR_ASYNC', '/tmp/patchright_profile_async')\n        browser = await p.chromium.launch_persistent_context(\n            user_data_dir=user_data_dir,\n            channel=\"chrome\",\n            headless=False,\n            viewport=None\n        )\n        page = await browser.new_page()\n        try:\n            print(f\"Navigating to example.com (async) with {p.chromium.name}...\")\n            await page.goto(\"https://example.com\")\n            print(f\"Page title (async): {await page.title()}\")\n            text = await page.locator('h1').inner_text()\n            print(f\"H1 text (async): {text}\")\n            await page.screenshot(path=f\"example-async-{p.chromium.name}.png\")\n            print(\"Screenshot saved (async).\")\n        finally:\n            await browser.close()\n            print(\"Browser closed (async).\")\n\nif __name__ == \"__main__\":\n    print(\"--- Running Synchronous Example ---\")\n    run_sync_example()\n    print(\"\\n--- Running Asynchronous Example ---\")\n    # Make sure to install browsers: `patchright install chrome`\n    asyncio.run(run_async_example())\n","lang":"python","description":"This quickstart demonstrates both synchronous and asynchronous usage of Patchright, highlighting the recommended configuration for maximum undetectability. It launches a persistent Chrome browser in non-headless mode, navigates to example.com, captures the page title and an H1 element's text, and takes a screenshot. The `user_data_dir` is made configurable via an environment variable for testing persistence. Remember to run `patchright install chrome` before executing.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-14","installed_version":"1.59.1","pypi_latest":"1.59.1","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":75,"avg_install_s":3.4,"avg_import_s":0.38,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"patchright","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"17.8M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"patchright","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"patchright","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.3,"import_time_s":0.14,"mem_mb":8,"disk_size":"156M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"patchright","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.18,"mem_mb":7.9,"disk_size":"154M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"patchright","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"19.6M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"patchright","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"patchright","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.4,"import_time_s":0.32,"mem_mb":9.3,"disk_size":"159M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"patchright","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.36,"mem_mb":9.2,"disk_size":"156M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"patchright","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"11.5M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"patchright","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"patchright","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.2,"import_time_s":0.49,"mem_mb":10.3,"disk_size":"151M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"patchright","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.87,"mem_mb":10.2,"disk_size":"148M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"patchright","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"11.2M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"patchright","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"patchright","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.2,"import_time_s":0.52,"mem_mb":10.8,"disk_size":"150M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"patchright","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.54,"mem_mb":10.8,"disk_size":"147M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"patchright","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"17.3M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"patchright","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"patchright","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.8,"import_time_s":0.19,"mem_mb":8.2,"disk_size":"156M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"patchright","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.18,"mem_mb":8.1,"disk_size":"153M"}]}}