Patchright Python wrapper with optional Turnstile auto-click helper.
Project description
patchright-difz
Patchright Python wrapper with an optional Turnstile helper.
Install
pip install patchright-difz
Sync usage
from patchright_difz.sync_api import sync_playwright
with sync_playwright() as p:
context = p.chromium.launch_persistent_context(
".profile",
headless=False,
channel="chrome",
no_viewport=True,
turnstile=True,
)
page = context.new_page()
page.goto("https://example.com")
Async usage
from patchright_difz.async_api import async_playwright
async with async_playwright() as p:
context = await p.chromium.launch_persistent_context(
".profile",
headless=False,
channel="chrome",
no_viewport=True,
turnstile=True,
)
page = await context.new_page()
await page.goto("https://example.com")
page.evaluate, frame.evaluate, locator evaluate helpers, and handle
evaluate helpers default to the page main world in this wrapper. If you need
Patchright's isolated world for a specific call, pass isolated_context=True.
The Turnstile helper uses Patchright locators for fallback detection, so it can also pick up challenge candidates rendered inside closed shadow roots.
When headless=True is used without a custom user_agent, the wrapper sets a
normal Chrome user agent before the first request. This applies to
launch_persistent_context, browser.new_context, and browser.new_page.
Set PATCHRIGHT_DIFZ_HEADLESS_USER_AGENT=0 to keep Patchright's default
headless user agent, or set it to a full user-agent string to override the
default.
Configure Turnstile
context = p.chromium.launch_persistent_context(
".profile",
headless=False,
channel="chrome",
no_viewport=True,
turnstile={
"timeout_ms": 5000,
"interval_ms": 2000,
"logger": print,
},
)
Camel-case option names from the npm package are also accepted:
timeoutMs, intervalMs, and maxCandidatesPerSelector.
Manual usage
from patchright_difz.sync_api import check_turnstile, sync_playwright
with sync_playwright() as p:
context = p.chromium.launch_persistent_context(
".profile",
headless=False,
channel="chrome",
no_viewport=True,
)
page = context.new_page()
page.goto("https://example.com")
check_turnstile(page)
Publish
python scripts/publish.py
The command builds, creates a v<version> git tag, pushes to GitHub, and lets
the GitHub Actions workflow publish to PyPI through Trusted Publishing.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file patchright_difz-0.3.0.tar.gz.
File metadata
- Download URL: patchright_difz-0.3.0.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7eba890413542f8e2635fce12204709e97aa957a53c1c59aa95607ddc21de11d
|
|
| MD5 |
35614df82de4c74589543d0deb86f9dc
|
|
| BLAKE2b-256 |
aca976e371e2c3f68c13971b6650d524f58933490c828a011f70dca6f4bc90cf
|
Provenance
The following attestation bundles were made for patchright_difz-0.3.0.tar.gz:
Publisher:
publish.yml on Difz25x/patchright-difz-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
patchright_difz-0.3.0.tar.gz -
Subject digest:
7eba890413542f8e2635fce12204709e97aa957a53c1c59aa95607ddc21de11d - Sigstore transparency entry: 1503336114
- Sigstore integration time:
-
Permalink:
Difz25x/patchright-difz-python@2a307cf964adea4e52bb02534b46a9818713cfd5 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Difz25x
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2a307cf964adea4e52bb02534b46a9818713cfd5 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file patchright_difz-0.3.0-py3-none-any.whl.
File metadata
- Download URL: patchright_difz-0.3.0-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6830709e28833d33952ffc23af4fa9f4c8abade14f4548e287c8df6de751683
|
|
| MD5 |
55a8ab87964150692158f5e3a3a8c398
|
|
| BLAKE2b-256 |
445dc216c2deae7ec002cbaf1ccff1bedd5a42d6381cb34f652c4b13c044fa81
|
Provenance
The following attestation bundles were made for patchright_difz-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on Difz25x/patchright-difz-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
patchright_difz-0.3.0-py3-none-any.whl -
Subject digest:
b6830709e28833d33952ffc23af4fa9f4c8abade14f4548e287c8df6de751683 - Sigstore transparency entry: 1503336411
- Sigstore integration time:
-
Permalink:
Difz25x/patchright-difz-python@2a307cf964adea4e52bb02534b46a9818713cfd5 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Difz25x
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2a307cf964adea4e52bb02534b46a9818713cfd5 -
Trigger Event:
workflow_dispatch
-
Statement type: