Skip to main content

Undetected Python version of the Playwright testing and automation library tweaked for a specific logic.

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


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)

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

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

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.

re_patchright-1.51.4-py3-none-win_amd64.whl (34.8 MB view details)

Uploaded Python 3Windows x86-64

re_patchright-1.51.4-py3-none-win32.whl (34.8 MB view details)

Uploaded Python 3Windows x86

re_patchright-1.51.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (44.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

re_patchright-1.51.4-py3-none-manylinux1_x86_64.whl (45.1 MB view details)

Uploaded Python 3

re_patchright-1.51.4-py3-none-macosx_11_0_universal2.whl (39.6 MB view details)

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

re_patchright-1.51.4-py3-none-macosx_11_0_arm64.whl (38.0 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

re_patchright-1.51.4-py3-none-macosx_10_13_x86_64.whl (39.6 MB view details)

Uploaded Python 3macOS 10.13+ x86-64

File details

Details for the file re_patchright-1.51.4-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for re_patchright-1.51.4-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 5e4b4f00b1661071a9b80d7329f06550889b668317c6cf8571f501115313bbad
MD5 a19decbdfa8f1cd7af25e24414da9def
BLAKE2b-256 c98e0e589db5bfa7506db21dc9dbdd5a735beda1e081598205839fad0aba620d

See more details on using hashes here.

Provenance

The following attestation bundles were made for re_patchright-1.51.4-py3-none-win_amd64.whl:

Publisher: patchright_workflow.yml on imamousenotacat/re-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 re_patchright-1.51.4-py3-none-win32.whl.

File metadata

  • Download URL: re_patchright-1.51.4-py3-none-win32.whl
  • Upload date:
  • Size: 34.8 MB
  • Tags: Python 3, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for re_patchright-1.51.4-py3-none-win32.whl
Algorithm Hash digest
SHA256 9e656c964525990a8cd655c0d52b551eff40bfa0407a7909e619e1a673354912
MD5 5ea514f9ac87d6570a2d7eff22406d16
BLAKE2b-256 3a80228e4e5c2acdbfd1c6ebd65bcc2ea59ba8d32f40dba0c144d55041006ee6

See more details on using hashes here.

Provenance

The following attestation bundles were made for re_patchright-1.51.4-py3-none-win32.whl:

Publisher: patchright_workflow.yml on imamousenotacat/re-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 re_patchright-1.51.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for re_patchright-1.51.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 73864b36b6ec3714754072fd971de55a9401b6ada0b32cd5a0e3b19da2dbb321
MD5 238137d78ea4b6a33f7b3111f878f57e
BLAKE2b-256 371d2a39db9a1805fa98908a2c24228841fdeb84f756c9d8d03b6d3180aefbb4

See more details on using hashes here.

Provenance

The following attestation bundles were made for re_patchright-1.51.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: patchright_workflow.yml on imamousenotacat/re-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 re_patchright-1.51.4-py3-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for re_patchright-1.51.4-py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 fd371d27212c8ba647e0e99034bd87e0e38bc78b8a5bbec2d58c875c2d3b3752
MD5 31eb932ced9d7715b78f70593daeabd6
BLAKE2b-256 e137c67305283d7a83903a5b26502104b0091a96793efeed51329b68d90184dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for re_patchright-1.51.4-py3-none-manylinux1_x86_64.whl:

Publisher: patchright_workflow.yml on imamousenotacat/re-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 re_patchright-1.51.4-py3-none-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for re_patchright-1.51.4-py3-none-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 98bef077ed37c46d3f34eaeea0b5fd90607a97339f0fe865794fcf997fa2d89c
MD5 df0d6e89bf9bcfc1264848e55d4a0204
BLAKE2b-256 435c9f28912682a72b72b4d106ae7cb680135634f6be858ce62579c027c593c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for re_patchright-1.51.4-py3-none-macosx_11_0_universal2.whl:

Publisher: patchright_workflow.yml on imamousenotacat/re-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 re_patchright-1.51.4-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for re_patchright-1.51.4-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0312251f2ed0aa5fab76d99d581b347cf4c86e2971510332624f04ebf1164156
MD5 a41d10e5dc815a6b8bd02b0c0065f00f
BLAKE2b-256 4d2c9f1a2499baa26388816e50dca357431f1d1b69a303207ae1e26dc65a4fc7

See more details on using hashes here.

Provenance

The following attestation bundles were made for re_patchright-1.51.4-py3-none-macosx_11_0_arm64.whl:

Publisher: patchright_workflow.yml on imamousenotacat/re-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 re_patchright-1.51.4-py3-none-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for re_patchright-1.51.4-py3-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 34012ce58aa525a1b50817dd1957349b1601bb128badd60abbe44046e5a818a1
MD5 bf6ac8179da48924126ee1dc5b6178b3
BLAKE2b-256 ec0addca5ac8444db5473151010327bfdcae85b6e010f408e716ef1f55caaac7

See more details on using hashes here.

Provenance

The following attestation bundles were made for re_patchright-1.51.4-py3-none-macosx_10_13_x86_64.whl:

Publisher: patchright_workflow.yml on imamousenotacat/re-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