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


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 (Frame.evaluate_all)

  • Added isolated_context to choose Execution Context (Main/Isolated). Bool (optional, Defaults to True)
Frame.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

patchright-1.52.5-py3-none-win_arm64.whl (30.7 MB view details)

Uploaded Python 3 Windows ARM64

patchright-1.52.5-py3-none-win_amd64.whl (34.8 MB view details)

Uploaded Python 3 Windows x86-64

patchright-1.52.5-py3-none-win32.whl (34.8 MB view details)

Uploaded Python 3 Windows x86

patchright-1.52.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (44.5 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

patchright-1.52.5-py3-none-macosx_11_0_universal2.whl (39.6 MB view details)

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

patchright-1.52.5-py3-none-macosx_11_0_arm64.whl (37.9 MB view details)

Uploaded Python 3 macOS 11.0+ ARM64

patchright-1.52.5-py3-none-macosx_10_13_x86_64.whl (39.6 MB view details)

Uploaded Python 3 macOS 10.13+ x86-64

File details

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

File metadata

File hashes

Hashes for patchright-1.52.5-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 f406911b5b3b21d70e3b1d1a2780b732575e31f2b012483622cc764166a31d78
MD5 5704b2b04db3b5512e512a28f42c42d6
BLAKE2b-256 9e6ab8f0fd8c513667b59b85d3969a5af65a5f2410ff41aff04d597ed5b872d0

See more details on using hashes here.

Provenance

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

Publisher: patchright_workflow.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.52.5-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for patchright-1.52.5-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 043e25cbb69e11db002770fde27eb14c59e5751f16969b4e3d4483e452537dc1
MD5 2bf198c1280c67d7178b0c226f789ad7
BLAKE2b-256 9e3be30391b7e610a6e0b536cfb92a01a6af2ca1fc2f3b37e69ad5a3982b94dc

See more details on using hashes here.

Provenance

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

Publisher: patchright_workflow.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.52.5-py3-none-win32.whl.

File metadata

  • Download URL: patchright-1.52.5-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 patchright-1.52.5-py3-none-win32.whl
Algorithm Hash digest
SHA256 127b70d12de28d6d70bf1033b386c7b787c58b5535750f915dfe0c6aec4a8bdf
MD5 8c7628aa1a3052bbc417673606f13500
BLAKE2b-256 b4587cb5211098f1665249af337843cfd1772ca3daa439cb77a042eefcb832b3

See more details on using hashes here.

Provenance

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

Publisher: patchright_workflow.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.52.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for patchright-1.52.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 804a67ac3faf1f1c06957ac6124c1e04faf8fa72aa15ccc5baea51c6740e8704
MD5 98a594b0ad6f1eca21b31145df8a5084
BLAKE2b-256 99a88ae90d5cba61af723d321e4eed1fee065609033ad9f2596e952f5e0d09f5

See more details on using hashes here.

Provenance

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

Publisher: patchright_workflow.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.52.5-py3-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for patchright-1.52.5-py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f53f6e79befbeb7ef42d00af42768a676bbb68d5674af824ae5fb2e9f0e339ec
MD5 79a32ea34a29afb712ed270585eaa2d9
BLAKE2b-256 530c78323bf5628bcf82f55220447d09bed54058add39ca214cdf1f9d1a13465

See more details on using hashes here.

Provenance

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

Publisher: patchright_workflow.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.52.5-py3-none-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for patchright-1.52.5-py3-none-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 88f64aa2fd647c349055ce0897ed9e5df50f4beb1da6224dd86f6fb9a66af693
MD5 accc360f58ce1982822ee213670dfcd0
BLAKE2b-256 3ea3b20fa2714fed92d976ae04585ebf4b52f514246f32f49b0b2600a2b5d083

See more details on using hashes here.

Provenance

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

Publisher: patchright_workflow.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.52.5-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for patchright-1.52.5-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d862436ba5401de4263aeade9fb2d9421f0ab1442a679eff2d8995f973682b06
MD5 fa085da502544094c48c7d1d23419bfa
BLAKE2b-256 f3316d48d2acc2641b0f120174746b18aadae85c501cac2f89d9165a2c099da9

See more details on using hashes here.

Provenance

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

Publisher: patchright_workflow.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.52.5-py3-none-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for patchright-1.52.5-py3-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 2d8d7755b55671b450e4153f0baa00bde2cf9a8edb42782c8b41f43707975314
MD5 088a1c4c47f337a2200732bc4a31c361
BLAKE2b-256 5f21807e0d7f672ab40095b493fd648d2dc9af72cd8df5a30055a0e8d572586b

See more details on using hashes here.

Provenance

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

Publisher: patchright_workflow.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 Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page