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.

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

Uploaded Python 3Windows ARM64

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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

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

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

Uploaded Python 3macOS 11.0+ ARM64

phantomwright_driver-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 phantomwright_driver-1.58.2-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for phantomwright_driver-1.58.2-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 32ef65ec149c3fa9c863f5e38aab41a6895725f20eccefcfbb9395fe9fac0cc7
MD5 d75243be1faf2667816bd5a3e8587528
BLAKE2b-256 4dc63d8bcd752f17c08431b5edba7e99315f8224ab7a9c86829f7b29ae6560bf

See more details on using hashes here.

Provenance

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

Publisher: patchright_release.yml on StudentWan/phantomwright-driver-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 phantomwright_driver-1.58.2-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for phantomwright_driver-1.58.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 bfcc9d7534421a277eb5419e630ca7bbd0414b80e3cd0de2d478b1db84b1d986
MD5 4688d53a3a95cb6cae83bd97d351f07c
BLAKE2b-256 160830697104dd3ffba91833d2e26f41c1e28f1621703f4dcfabc6b3d0876f46

See more details on using hashes here.

Provenance

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

Publisher: patchright_release.yml on StudentWan/phantomwright-driver-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 phantomwright_driver-1.58.2-py3-none-win32.whl.

File metadata

File hashes

Hashes for phantomwright_driver-1.58.2-py3-none-win32.whl
Algorithm Hash digest
SHA256 2e8996a76818ab74555b9e3839bcbcaa70eaec221eea73cc016d4baedf3181ac
MD5 d2619ae848c16460355a1c7a181a648e
BLAKE2b-256 4069f5b0f033dafbd24197f4c10679fac6108fdbb633fb6783ad615ffdaa1754

See more details on using hashes here.

Provenance

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

Publisher: patchright_release.yml on StudentWan/phantomwright-driver-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 phantomwright_driver-1.58.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for phantomwright_driver-1.58.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bad59912f245bf10de3994ed7edb11cedb273d5fdea879095fd72a1b4f0a5db9
MD5 21f83ebcc234a98100561611c70198b5
BLAKE2b-256 aeb21737ffeae04c79c6034379882a224f9283941da36838113aa5a3f85bf569

See more details on using hashes here.

Provenance

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

Publisher: patchright_release.yml on StudentWan/phantomwright-driver-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 phantomwright_driver-1.58.2-py3-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for phantomwright_driver-1.58.2-py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9e0a984be4e88188de8a4b38c1e5f855279400a667392ebe25b88e0a3b551b08
MD5 c744d17e23e83b43cf73d740ccb76442
BLAKE2b-256 151d8872d5870a2f0e2448556d214d15ce14d390dbe8d192640352ca8be809f0

See more details on using hashes here.

Provenance

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

Publisher: patchright_release.yml on StudentWan/phantomwright-driver-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 phantomwright_driver-1.58.2-py3-none-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for phantomwright_driver-1.58.2-py3-none-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 fcad7bbdf7958bb6c134d2ff1b41b2c4925c6a2666b91d2a44d0cf39a0584b88
MD5 f722b5022ac58326349c529f0abcb40b
BLAKE2b-256 1ae6dda16d6a9fc84eda4ecef8ddbac3a6d0fea183e00fd379e7053d8b3c35f5

See more details on using hashes here.

Provenance

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

Publisher: patchright_release.yml on StudentWan/phantomwright-driver-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 phantomwright_driver-1.58.2-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for phantomwright_driver-1.58.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ed6508832398c82932866d3c3d5ce46a26963f313dd2cb7a864d5961aad49a32
MD5 27e254176fdfd81002626fd184db41c7
BLAKE2b-256 91c359e5791e354bfa40818a6277c2414889a346690798855c29d83537b2092c

See more details on using hashes here.

Provenance

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

Publisher: patchright_release.yml on StudentWan/phantomwright-driver-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 phantomwright_driver-1.58.2-py3-none-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for phantomwright_driver-1.58.2-py3-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 75c9bef19963d484e4aa73a20b9b418425a7e9de6bf71a14c3fff50a00a5bb06
MD5 1b6fcf19534e6baf29d5d86af46626b4
BLAKE2b-256 8f232baee18f680d01a10a0f1710b801e077ea16e453604e9de28b5c625521e6

See more details on using hashes here.

Provenance

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

Publisher: patchright_release.yml on StudentWan/phantomwright-driver-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