MCPcopy Index your code
hub / github.com/Kaliiiiiiiiii-Vinyzu/patchright-python

github.com/Kaliiiiiiiiii-Vinyzu/patchright-python @v1.61.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.61.0 ↗ · + Follow
6 symbols 19 edges 2 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

🎭 Patchright Python

<a href="https://github.com/Kaliiiiiiiiii-Vinyzu/patchright-python/blob/main/LICENSE">
    <img src="https://img.shields.io/badge/License-Apache%202.0-green">
</a>
<a>
    <img src="https://img.shields.io/badge/Based%20on-Playwright-goldenrod">
</a>
<a>
    <img src="https://img.shields.io/badge/Driver-Patched-blue">
</a>
<a href="https://github.com/Kaliiiiiiiiii-Vinyzu/patchright-python/actions/workflows/patchright_tests.yml">
    <img src="https://github.com/Kaliiiiiiiiii-Vinyzu/patchright-python/actions/workflows/patchright_tests.yml/badge.svg">
</a>



<a href="https://github.com/Kaliiiiiiiiii-Vinyzu/patchright-python/releases/latest">
    <img alt="Patchright Version" src="https://img.shields.io/github/v/release/microsoft/playwright-python?display_name=release&label=Version">
</a>
<a href="https://github.com/Kaliiiiiiiiii-Vinyzu/patchright-python">
    <img src="https://img.shields.io/badge/Package-Python-seagreen">
</a>
<a href="https://github.com/Kaliiiiiiiiii-Vinyzu/patchright-python/releases">
    <img alt="GitHub Downloads (all assets, all releases)" src="https://img.shields.io/pepy/dt/patchright?color=red">
</a>

Patchright is a patched and undetected version of the Playwright Testing and Automation Framework.

It can be used as a drop-in replacement for Playwright.

[!NOTE]
This repository serves the Patchright-Python Package. To use Patchright with NodeJS, check out the NodeJS Package. Also check out the main Patchright Driver Repository


Sponsors

Want to Sponsor this Project? Contact [@vinyzu](https://discordapp.com/users/935224495126487150) on Discord! [swiftproxy banner](https://www.swiftproxy.net/?ref=Vinyzu) #### [Swiftproxy](https://www.swiftproxy.net/?ref=Vinyzu): High-Performance Residential Proxies for Scalable Data Collection Built for developers who need **reliable**, anti-detection proxy infrastructure. [Swiftproxy](https://www.swiftproxy.net/?ref=Vinyzu) delivers **stable connections**, **high success rates**, and flexible control for **large-scale scraping and automation**. - 🌍 195+ locations with ethically sourced residential IPs - 🔄 **Rotating** & **sticky sessions** with precise geo-targeting - ⚡ Optimized for **anti-ban** & **high success rate** - 🔌 HTTP / HTTPS / SOCKS5 support - 🧪 **Free 500MB trial** for testing - 💸 **Special discount** code for Patchright users: **PROXY90 - 10%** Best for: Web scraping, automation, multi-accounting, and large-scale data extraction --- [rapidproxy banner](https://www.rapidproxy.io/?ref=Vinyzu) #### [RapidProxy](https://www.rapidproxy.io/?ref=Vinyzu) provides a stable and high-performance proxy network built for large-scale data operations. [RapidProxy](https://www.rapidproxy.io/?ref=Vinyzu) delivers: - 🌍 90M+ Residential IPs (200+ locations) - 🔄 **Rotating Residential Proxies** — from **$0.65/GB** (non-expiring traffic) - 🧩 **Static Residential IPs** — **$5/IP** (30 days, unlimited traffic) - 🎯 Precise geo-targeting - ⚡ **Free Trial Available** — test proxy performance risk-free - Built for scraping, automation, and high-performance data workflows. - 🔥 Special Offer: Use code **RAPID10** to get **10% off** Start fast. Scale globally. Stay stable with [RapidProxy](https://www.rapidproxy.io/?ref=Vinyzu). --- [NodeMaven Banner](https://go.nodemaven.com/Vinyzu) #### [NodeMaven](https://go.nodemaven.com/Vinyzu): Your reliable proxy provider with High Quality IPs. Superb solution for automation, web scraping, SEO research, and social media management. Why [NodeMaven](https://go.nodemaven.com/Vinyzu)? ✅ 99.9% Uptime 🎯 Sticky sessions up to 7 days 🔍 IP Filtering: Proxies are guaranteed to have fraud score <97% 🔰 No KYC required 💸 Cashback on Traffic - Burn GB and earn up to 10% back **Special codes** for Patchright users: 🔥 **PATCHRIGHT35** - **35% off** to Mobile and Residential Proxies 🔥 **PATCHRIGHT40** - **40% off** to ISP (Static) Proxies Choose quality and stability with [NodeMaven](https://go.nodemaven.com/Vinyzu). --- [ColaProxy Banner](https://colaproxy.com/?utm_source=viny&utm_medium=viny&ref=viny) #### [**ColaProxy**](https://colaproxy.com/?utm_source=viny&utm_medium=viny&ref=viny) : Low-Cost Residential Proxies for Scalable Automation, Scraping, and Global Data Access Why choose [**ColaProxy**](https://colaproxy.com/?utm_source=viny&utm_medium=viny&ref=viny)? * Dynamic Residential Proxies from as low as **$0.3/GB** * Massive residential IP pool across 195+ countries * 99.9% uptime with stable and fast connections * HTTP / HTTPS / SOCKS5 protocol support * Rotating & sticky sessions for flexible automation * Precise country-level geo-targeting * 24/7 expert support Need reliable proxies for Patchright automation? [ColaProxy](https://colaproxy.com/?utm_source=viny&utm_medium=viny&ref=viny) offers cost-effective residential, ISP, and mobile proxy solutions for scraping, testing, account management, SEO monitoring, and global data collection. Use coupon code **COLA20** to enjoy 20% off your order. Affordable, stable, and built for developers. Start scaling your Patchright projects with [**ColaProxy**](https://colaproxy.com/?utm_source=viny&utm_medium=viny&ref=viny). --- ## Install it from PyPI
# Install Patchright with Pip from PyPI
pip install patchright
# Install Chromium-Driver for Patchright
patchright install chromium
--- ## Usage #### Just change the import and use it like playwright. Patchright is a drop-in-replacement for Playwright! > [!IMPORTANT] > Patchright only patches CHROMIUM based browsers. Firefox and Webkit are not supported.
# patchright here!
from patchright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.goto('http://playwright.dev')
    page.screenshot(path=f'example-{p.chromium.name}.png')
    browser.close()
import asyncio
# patchright here!
from patchright.async_api import async_playwright

async def main():
    async with async_playwright() as p:
        browser = await p.chromium.launch()
        page = await browser.new_page()
        await page.goto('http://playwright.dev')
        await page.screenshot(path=f'example-{p.chromium.name}.png')
        await browser.close()

asyncio.run(main())
### Best Practice - use Chrome without Fingerprint Injection To be completely undetected, use the following configuration:
playwright.chromium.launch_persistent_context(
    user_data_dir="...",
    channel="chrome",
    headless=False,
    no_viewport=True,
    # do NOT add custom browser headers or user_agent
    ...
)
> [!NOTE] > We recommend using Google Chrome instead of Chromium. > You can install it via `patchright install chrome` (or via any other installation method) and use it with `channel="chrome"`. --- ## Patches ### [Runtime.enable](https://vanilla.aslushnikov.com/?Runtime.enable) Leak This is the biggest Patch Patchright uses. To avoid detection by this leak, patchright avoids using [Runtime.enable](https://vanilla.aslushnikov.com/?Runtime.enable) by executing Javascript in (isolated) ExecutionContexts. ### [Console.enable](https://vanilla.aslushnikov.com/?Console.enable) Leak Patchright patches this leak by disabling the Console API all together. This means, console functionality will not work in Patchright. If you really need the console, you might be better off using Javascript loggers, although they also can be easily detected. ### Command Flags Leaks Patchright tweaks the Playwright Default Args to avoid detection by Command Flag Leaks. This (most importantly) affects: - `--disable-blink-features=AutomationControlled` (added) to avoid navigator.webdriver detection. - `--enable-automation` (removed) to avoid navigator.webdriver detection. - `--disable-popup-blocking` (removed) to avoid popup crashing. - `--disable-component-update` (removed) to avoid detection as a Stealth Driver. - `--disable-default-apps` (removed) to enable default apps. - `--disable-extensions` (removed) to enable extensions ### General Leaks Patchright patches some general leaks in the Playwright codebase. This mainly includes poor setups and obvious detection points. ### Closed Shadow Roots Patchright is able to interact with elements in Closed Shadow Roots. Just use normal locators and Patchright will do the rest. Patchright is now also able to use XPaths in Closed Shadow Roots. --- ## Stealth With the right setup, Patchright currently is considered undetectable. Patchright passes: - [Brotector](https://kaliiiiiiiiii.github.io/brotector/) ✅ (with [CDP-Patches](https://github.com/Kaliiiiiiiiii-Vinyzu/CDP-Patches/)) - [Cloudflare](https://cloudflare.com/) ✅ - [Kasada](https://www.kasada.io/) ✅ - [Akamai](https://www.akamai.com/products/bot-manager/) ✅ - [Shape/F5](https://www.f5.com/) ✅ - [Bet365](https://bet365.com/) ✅ - [Datadome](https://datadome.co/products/bot-protection/) ✅ - [Fingerprint.com](https://fingerprint.com/products/bot-detection/) ✅ - [CreepJS](https://abrahamjuliot.github.io/creepjs/) ✅ - [Sannysoft](https://bot.sannysoft.com/) ✅ - [Incolumitas](https://bot.incolumitas.com/) ✅ - [IPHey](https://iphey.com/) ✅ - [Browserscan](https://browserscan.net/) ✅ - [Pixelscan](https://pixelscan.net/) ✅ --- ## Documentation and API Reference See the original [Playwright Documentation](https://playwright.dev/python/docs/intro) and [API Reference](https://playwright.dev/python/docs/api/class-playwright) ## Extended Patchright API #### **`evaluate`** Method ([`Frame.evaluate`](https://playwright.dev/python/docs/api/class-frame#frame-evaluate), [`Page.evaluate`](https://playwright.dev/python/docs/api/class-page#page-evaluate), [`Locator.evaluate`](https://playwright.dev/python/docs/api/class-locator#locator-evaluate), [`Worker.evaluate`](https://playwright.dev/python/docs/api/class-worker#worker-evaluate), [`JSHandle.evaluate`](https://playwright.dev/python/docs/api/class-jshandle#js-handle-evaluate)) - Added `isolated_context` to choose Execution Context (Main/Isolated). `Bool` (*optional*, Defaults to `True`)
object.evaluate(
    expression: str,
    arg: typing.Optional[typing.Any] = None,
    ...,
+   isolated_context: typing.Optional[bool] = True
)
#### **`evaluate_handle`** Method ([`Frame.evaluate_handle`](https://playwright.dev/python/docs/api/class-frame#frame-evaluate-handle), [`Page.evaluate_handle`](https://playwright.dev/python/docs/api/class-page#page-evaluate-handle), [`Locator.evaluate_handle`](https://playwright.dev/python/docs/api/class-locator#locator-evaluate-handle), [`Worker.evaluate_handle`](https://playwright.dev/python/docs/api/class-worker#worker-evaluate-handle), [`JSHandle.evaluate`](https://playwright.dev/python/docs/api/class-jshandle#js-handle-evaluate-handle)) - Added `isolated_context` to choose Execution Context (Main/Isolated). `Bool` (*optional*, Defaults to `True`)
object.evaluate_handle(
    expression: str,
    arg: typing.Optional[typing.Any] = None,
    ...,
+   isolated_context: typing.Optional[bool] = True
)
#### **`evaluate_all`** Method ([`Locator.evaluate_all`](https://playwright.dev/python/docs/next/api/class-locator#locator-evaluate-all)) - Added `isolated_context` to choose Execution Context (Main/Isolated). `Bool` (*optional*, Defaults to `True`)
Locator.evaluate_all(
    expression: str,
    arg: typing.Optional[typing.Any] = None,
    ...,
+   isolated_context: typing.Optional[bool] = True
)
--- ## Bugs #### The bugs are documented in the [Patchright Driver Repository](https://github.com/Kaliiiiiiiiii-Vinyzu/patchright#bugs). --- ### TODO #### The TODO is documented in the [Patchright Driver Repository](https://github.com/Kaliiiiiiiiii-Vinyzu/patchright#todo). --- ## Development Deployment of new Patchright versions are automatic, but bugs due to Playwright codebase changes may occur. Fixes for these bugs might take a few days to be released. --- ## Support our work If you choose to support our work, please contact [@vinyzu](https://discord.com/users/935224495126487150) or [@steve_abcdef](https://discord.com/users/936292409426477066) on Discord. --- ## Copyright and License © [Vinyzu](https://github.com/Vinyzu/) Patchright is licensed [Apache 2.0](https://choosealicense.com/licenses/apache-2.0/) --- ## Disclaimer This repository is provided for **educational purposes only**. \ No warranties are provided regarding accuracy, completeness, or suitability for any purpose. **Use at your own risk**—the authors and maintainers assume **no liability** for **any damages**, **legal issues**, or **warranty breaches** resulting from use, modification, or distribution of this code.\ **Any misuse or legal violations are the sole responsibility of the user**. --- ## Authors #### Active Maintainer: [Vinyzu](https://github.com/Vinyzu/) Co-Maintainer: [Kaliiiiiiiiii](https://github.com/kaliiiiiiiiii/)

Core symbols most depended-on inside this repo

patch_file
called by 17
patch_python_package.py

Shape

Function 3
Method 2
Class 1

Languages

Python100%

Modules by API surface

utils/modify_tests.py5 symbols
patch_python_package.py1 symbols

For agents

$ claude mcp add patchright-python \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact