Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Undetected Python version of the Playwright testing and automation library.

License

NotificationsYou must be signed in to change notification settings

Kaliiiiiiiiii-Vinyzu/patchright-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Patchright VersionGitHub 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 theNodeJS Package.Also check out the mainPatchright Driver Repository


Install it from PyPI

# Install Patchright with Pip from PyPIpip install patchright
# Install Chromium-Driver for Patchrightpatchright 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!frompatchright.sync_apiimportsync_playwrightwithsync_playwright()asp:browser=p.chromium.launch()page=browser.new_page()page.goto('http://playwright.dev')page.screenshot(path=f'example-{p.chromium.name}.png')browser.close()
importasyncio# patchright here!frompatchright.async_apiimportasync_playwrightasyncdefmain():asyncwithasync_playwright()asp:browser=awaitp.chromium.launch()page=awaitbrowser.new_page()awaitpage.goto('http://playwright.dev')awaitpage.screenshot(path=f'example-{p.chromium.name}.png')awaitbrowser.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 viapatchright install chrome (or via any other installation method) and use it withchannel="chrome".


Patches

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

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 originalPlaywright Documentation andAPI Reference

Extended Patchright API

  • Addedisolated_context to choose Execution Context (Main/Isolated).Bool (optional, Defaults toTrue)
object.evaluate(    expression: str,    arg: typing.Optional[typing.Any] = None,    ...,+   isolated_context: typing.Optional[bool] = True)
  • Addedisolated_context to choose Execution Context (Main/Isolated).Bool (optional, Defaults toTrue)
object.evaluate_handle(    expression: str,    arg: typing.Optional[typing.Any] = None,    ...,+   isolated_context: typing.Optional[bool] = True)

evaluate_all Method(Locator.evaluate_all)

  • Addedisolated_context to choose Execution Context (Main/Isolated).Bool (optional, Defaults toTrue)
Locator.evaluate_all(    expression: str,    arg: typing.Optional[typing.Any] = None,    ...,+   isolated_context: typing.Optional[bool] = True)

Bugs

The bugs are documented in thePatchright Driver Repository.


TODO

The TODO is documented in thePatchright 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 licensedApache 2.0


Disclaimer

This repository is provided foreducational purposes only.
No warranties are provided regarding accuracy, completeness, or suitability for any purpose.Use at your own risk—the authors and maintainers assumeno liability forany damages,legal issues, orwarranty 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


[8]ページ先頭

©2009-2025 Movatter.jp