Skip to main content

Undetected Python version of the Playwright testing and automation library.

Project description

🎭 Patchright Python


Patchright Version GitHub Downloads (all assets, all releases)

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

Thordata Banner

Thordata - Your First Plan is on Us! 💰Get 100% of your first residential proxy purchase back as wallet balance, up to $900.

⚡ Why Thordata?

🌍 190+ real residential & ISP IP locations
🔐 Fully encrypted, ultra-secure connections
🚀 Optimized for web scraping, ad verification & automation workflows

🔥Don’t wait — this is your best time to start with Thordata and experience the safest, fastest proxy network.


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 Leak

This is the biggest Patch Patchright uses. To avoid detection by this leak, patchright avoids using Runtime.enable by executing Javascript in (isolated) ExecutionContexts.

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:


Documentation and API Reference

See the original Playwright Documentation and API Reference

Extended Patchright API

evaluate Method (Frame.evaluate, Page.evaluate, Locator.evaluate, Worker.evaluate, JSHandle.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, Page.evaluate_handle, Locator.evaluate_handle, Worker.evaluate_handle, JSHandle.evaluate)

  • 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)

  • 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.


TODO

The TODO is documented in the Patchright Driver Repository.


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 or @steve_abcdef on Discord.


Copyright and License

© Vinyzu

Patchright is licensed 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
Co-Maintainer: Kaliiiiiiiiii

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

patchright-1.58.2-py3-none-win_arm64.whl (33.1 MB view details)

Uploaded Python 3Windows ARM64

patchright-1.58.2-py3-none-win_amd64.whl (36.8 MB view details)

Uploaded Python 3Windows x86-64

patchright-1.58.2-py3-none-win32.whl (36.8 MB view details)

Uploaded Python 3Windows x86

patchright-1.58.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (46.0 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

patchright-1.58.2-py3-none-manylinux1_x86_64.whl (46.2 MB view details)

Uploaded Python 3

patchright-1.58.2-py3-none-macosx_11_0_universal2.whl (42.2 MB view details)

Uploaded Python 3macOS 11.0+ universal2 (ARM64, x86-64)

patchright-1.58.2-py3-none-macosx_11_0_arm64.whl (41.0 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

patchright-1.58.2-py3-none-macosx_10_13_x86_64.whl (42.2 MB view details)

Uploaded Python 3macOS 10.13+ x86-64

File details

Details for the file patchright-1.58.2-py3-none-win_arm64.whl.

File metadata

  • Download URL: patchright-1.58.2-py3-none-win_arm64.whl
  • Upload date:
  • Size: 33.1 MB
  • Tags: Python 3, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for patchright-1.58.2-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 958cd884787d140dd464ec2901ea85b9634aad5e8444a267f407ee648de04667
MD5 77e5e597c5c5688bdf3d5a190a07ae2e
BLAKE2b-256 f5aea85dca1ebcdfc63e5838783c0929d82066dacd7448e29911d052bbd286cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for patchright-1.58.2-py3-none-win_arm64.whl:

Publisher: patchright_release.yml on Kaliiiiiiiiii-Vinyzu/patchright-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file patchright-1.58.2-py3-none-win_amd64.whl.

File metadata

  • Download URL: patchright-1.58.2-py3-none-win_amd64.whl
  • Upload date:
  • Size: 36.8 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for patchright-1.58.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 9b740c13343a6e412efe052d0c17a65910cc4e3fd0fd6b62c1ac8dc1eec4c158
MD5 0716f6beb887f69641eb056e8eb3695b
BLAKE2b-256 c411f06d2f6ae8e0c1aea4b17b18a105dc2ad28e358217896eb3720e80e2d297

See more details on using hashes here.

Provenance

The following attestation bundles were made for patchright-1.58.2-py3-none-win_amd64.whl:

Publisher: patchright_release.yml on Kaliiiiiiiiii-Vinyzu/patchright-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file patchright-1.58.2-py3-none-win32.whl.

File metadata

  • Download URL: patchright-1.58.2-py3-none-win32.whl
  • Upload date:
  • Size: 36.8 MB
  • Tags: Python 3, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for patchright-1.58.2-py3-none-win32.whl
Algorithm Hash digest
SHA256 7dac724893fde90d726b125f7c35507a2afb5480c23cb57f88a31484d131de98
MD5 92025fddf38af0026918ec562ffe4751
BLAKE2b-256 bb633b054f25a44721b9a530ec12de33d6b5d94cd9952748c2586b2a64ef62ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for patchright-1.58.2-py3-none-win32.whl:

Publisher: patchright_release.yml on Kaliiiiiiiiii-Vinyzu/patchright-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file patchright-1.58.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for patchright-1.58.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0e68d0c538b5bd2bd6ef0b1327e9e766c3919d5aeade8b7bd4b29ecd3adfc0b4
MD5 0abea2687c2234872d0dbc79bdda9fb8
BLAKE2b-256 bcd933f3c4839ddbc3255ab012457220d56d7a910174a0a41424f6424a8b156f

See more details on using hashes here.

Provenance

The following attestation bundles were made for patchright-1.58.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: patchright_release.yml on Kaliiiiiiiiii-Vinyzu/patchright-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file patchright-1.58.2-py3-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for patchright-1.58.2-py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 13aef416c59f23f0fb552658281890ef349db2bee2e449c159560867c2e6cb61
MD5 9bb8162c19a366c63d8915281a32d2f3
BLAKE2b-256 e52bcb8b7053f2ede3586d89cb7e45f7b643751f8d97b4dfa9af7f4188aac3f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for patchright-1.58.2-py3-none-manylinux1_x86_64.whl:

Publisher: patchright_release.yml on Kaliiiiiiiiii-Vinyzu/patchright-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file patchright-1.58.2-py3-none-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for patchright-1.58.2-py3-none-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 8dc1005c5683c8661de461e5ee85f857b43758f1e2599a7d8a44c50c6ad9c5d7
MD5 cf413062b0ebda4b78078a53ba2e55f9
BLAKE2b-256 ba085c97f3f3300a93c62b417b5dac86d22ad771e0941cd5b59c6054d7716197

See more details on using hashes here.

Provenance

The following attestation bundles were made for patchright-1.58.2-py3-none-macosx_11_0_universal2.whl:

Publisher: patchright_release.yml on Kaliiiiiiiiii-Vinyzu/patchright-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file patchright-1.58.2-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for patchright-1.58.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 be76fa83f5b36219375fc0ed52f76de800eb2388844c185bb857a2e107caea13
MD5 5cea50115e935bbf37fe18970e348416
BLAKE2b-256 9b38e8f173299b05bbf5fd0278fbee5ceaf25eab93fece203bb5b08ae924d604

See more details on using hashes here.

Provenance

The following attestation bundles were made for patchright-1.58.2-py3-none-macosx_11_0_arm64.whl:

Publisher: patchright_release.yml on Kaliiiiiiiiii-Vinyzu/patchright-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file patchright-1.58.2-py3-none-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for patchright-1.58.2-py3-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 3930464552e52f4d5283998db5797e1797c1869206bce25c065b2d84a69e6bfb
MD5 453ce19f8f82b682ae59b2b315e59f73
BLAKE2b-256 412fafacd242f1ac8265275531c2e1be387f0c3b87ed14accff118c1e824695e

See more details on using hashes here.

Provenance

The following attestation bundles were made for patchright-1.58.2-py3-none-macosx_10_13_x86_64.whl:

Publisher: patchright_release.yml on Kaliiiiiiiiii-Vinyzu/patchright-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page