patchright-cli 0.1.0__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {patchright_cli-0.1.0 → patchright_cli-0.2.0}/.gitignore +1 -0
- patchright_cli-0.2.0/CONTRIBUTING.md +44 -0
- {patchright_cli-0.1.0 → patchright_cli-0.2.0}/PKG-INFO +143 -48
- patchright_cli-0.2.0/README.md +378 -0
- patchright_cli-0.2.0/docs/installation.md +174 -0
- {patchright_cli-0.1.0 → patchright_cli-0.2.0}/pyproject.toml +1 -1
- {patchright_cli-0.1.0 → patchright_cli-0.2.0}/skills/patchright-cli/SKILL.md +39 -5
- {patchright_cli-0.1.0 → patchright_cli-0.2.0}/src/patchright_cli/__init__.py +1 -1
- {patchright_cli-0.1.0 → patchright_cli-0.2.0}/src/patchright_cli/cli.py +6 -6
- {patchright_cli-0.1.0 → patchright_cli-0.2.0}/src/patchright_cli/daemon.py +80 -35
- patchright_cli-0.1.0/README.md +0 -283
- patchright_cli-0.1.0/docs/installation.md +0 -68
- {patchright_cli-0.1.0 → patchright_cli-0.2.0}/.github/workflows/publish.yml +0 -0
- {patchright_cli-0.1.0 → patchright_cli-0.2.0}/.pre-commit-config.yaml +0 -0
- {patchright_cli-0.1.0 → patchright_cli-0.2.0}/LICENSE +0 -0
- {patchright_cli-0.1.0 → patchright_cli-0.2.0}/patchright-cli +0 -0
- {patchright_cli-0.1.0 → patchright_cli-0.2.0}/patchright-cli.cmd +0 -0
- {patchright_cli-0.1.0 → patchright_cli-0.2.0}/src/patchright_cli/__main__.py +0 -0
- {patchright_cli-0.1.0 → patchright_cli-0.2.0}/src/patchright_cli/snapshot.py +0 -0
- {patchright_cli-0.1.0 → patchright_cli-0.2.0}/uv.lock +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Contributing to patchright-cli
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in contributing! Here's how to get started.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/AhaiMk01/patchright-cli.git
|
|
9
|
+
cd patchright-cli
|
|
10
|
+
uv venv && uv pip install -e .
|
|
11
|
+
python -m patchright install chromium
|
|
12
|
+
pre-commit install
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Making Changes
|
|
16
|
+
|
|
17
|
+
1. Fork the repo and create a branch from `main`
|
|
18
|
+
2. Make your changes
|
|
19
|
+
3. Run `pre-commit run --all-files` to check linting
|
|
20
|
+
4. Test your changes manually with `patchright-cli`
|
|
21
|
+
5. Commit and open a PR
|
|
22
|
+
|
|
23
|
+
## What to Contribute
|
|
24
|
+
|
|
25
|
+
- Bug fixes
|
|
26
|
+
- New commands (check playwright-cli for parity gaps)
|
|
27
|
+
- Snapshot accuracy improvements
|
|
28
|
+
- Platform compatibility fixes (Windows/macOS/Linux)
|
|
29
|
+
- Documentation improvements
|
|
30
|
+
- Tests
|
|
31
|
+
|
|
32
|
+
## Code Style
|
|
33
|
+
|
|
34
|
+
- Python 3.10+
|
|
35
|
+
- Formatted with [Ruff](https://github.com/astral-sh/ruff) (enforced via pre-commit)
|
|
36
|
+
- Keep the daemon lightweight — avoid heavy dependencies
|
|
37
|
+
|
|
38
|
+
## Reporting Issues
|
|
39
|
+
|
|
40
|
+
Open an issue with:
|
|
41
|
+
- What you expected
|
|
42
|
+
- What happened
|
|
43
|
+
- Steps to reproduce
|
|
44
|
+
- OS and Python version
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: patchright-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Anti-detect browser automation CLI using Patchright (undetected Playwright fork)
|
|
5
5
|
Project-URL: Homepage, https://github.com/AhaiMk01/patchright-cli
|
|
6
6
|
Project-URL: Repository, https://github.com/AhaiMk01/patchright-cli
|
|
@@ -28,59 +28,90 @@ Description-Content-Type: text/markdown
|
|
|
28
28
|
|
|
29
29
|
# patchright-cli
|
|
30
30
|
|
|
31
|
-
<!-- badges (hidden until PyPI publish)
|
|
32
31
|
[](https://pypi.org/project/patchright-cli/)
|
|
33
32
|
[](https://pypi.org/project/patchright-cli/)
|
|
34
|
-
[](LICENSE)
|
|
35
33
|
[](https://pypi.org/project/patchright-cli/)
|
|
36
|
-
|
|
34
|
+
[](LICENSE)
|
|
35
|
+
[](https://github.com/AhaiMk01/patchright-cli/actions)
|
|
36
|
+
[](https://github.com/AhaiMk01/patchright-cli)
|
|
37
|
+
[](https://github.com/AhaiMk01/patchright-cli/issues)
|
|
38
|
+
[](https://github.com/astral-sh/ruff)
|
|
37
39
|
|
|
38
40
|
Anti-detect browser automation CLI. Same command interface as [Microsoft's playwright-cli](https://github.com/microsoft/playwright-cli) but using [Patchright](https://github.com/kaliiiiiiiiii/patchright-python) (undetected Playwright fork) to bypass bot detection.
|
|
39
41
|
|
|
40
|
-
|
|
42
|
+
[Install](#install) · [Quick Start](#quick-start) · [Commands](#-commands) · [Snapshots](#snapshots) · [Agent Integration](#agent-integration)
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
### Highlights
|
|
43
45
|
|
|
44
|
-
|
|
46
|
+
| | Feature |
|
|
47
|
+
|---|---|
|
|
48
|
+
| :shield: | Bypasses Akamai, Cloudflare, and other anti-bot systems |
|
|
49
|
+
| :rocket: | Same command interface as playwright-cli — zero learning curve |
|
|
50
|
+
| :robot: | Built for AI agents (Claude Code, Codex, etc.) with YAML snapshots |
|
|
51
|
+
| :zap: | Daemon architecture — browser stays open between commands |
|
|
52
|
+
| :package: | `pip install` / `uvx` — no Docker, no config files |
|
|
53
|
+
| :lock: | Persistent profiles for maintaining login sessions |
|
|
45
54
|
|
|
46
|
-
|
|
55
|
+
---
|
|
47
56
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Just tell your AI agent:
|
|
57
|
+
## Install
|
|
51
58
|
|
|
59
|
+
> [!TIP]
|
|
60
|
+
> **Just paste this into your AI coding agent — it will do the rest:**
|
|
61
|
+
>
|
|
62
|
+
> ```
|
|
52
63
|
> Install and set up patchright-cli by following the instructions here:
|
|
53
64
|
> https://raw.githubusercontent.com/AhaiMk01/patchright-cli/main/docs/installation.md
|
|
65
|
+
> ```
|
|
66
|
+
>
|
|
67
|
+
> Your agent handles the install, browser setup, and skill configuration automatically.
|
|
54
68
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
### For LLM Agents
|
|
69
|
+
<details>
|
|
70
|
+
<summary><b>For LLM Agents</b></summary>
|
|
58
71
|
|
|
59
72
|
```bash
|
|
60
73
|
curl -s https://raw.githubusercontent.com/AhaiMk01/patchright-cli/main/docs/installation.md
|
|
61
74
|
```
|
|
62
75
|
|
|
63
|
-
|
|
76
|
+
</details>
|
|
77
|
+
|
|
78
|
+
> [!IMPORTANT]
|
|
79
|
+
> **Requirements:** Python 3.10+ and Google Chrome
|
|
80
|
+
|
|
81
|
+
<details>
|
|
82
|
+
<summary><b>Manual Install</b></summary>
|
|
64
83
|
|
|
65
84
|
```bash
|
|
66
|
-
#
|
|
67
|
-
pip install patchright-cli
|
|
85
|
+
# 1. Install the package
|
|
86
|
+
pip install patchright-cli # or: uv tool install patchright-cli
|
|
87
|
+
|
|
88
|
+
# 2. Install the Patchright browser (fallback if Chrome is not found)
|
|
89
|
+
python -m patchright install chromium
|
|
90
|
+
|
|
91
|
+
# 3. Verify
|
|
92
|
+
patchright-cli open https://example.com
|
|
93
|
+
patchright-cli close
|
|
94
|
+
```
|
|
68
95
|
|
|
69
|
-
|
|
70
|
-
uv tool install patchright-cli
|
|
96
|
+
Or run without installing (like npx):
|
|
71
97
|
|
|
72
|
-
|
|
98
|
+
```bash
|
|
73
99
|
uvx patchright-cli open https://example.com
|
|
74
100
|
```
|
|
75
101
|
|
|
76
|
-
|
|
102
|
+
**From source:**
|
|
77
103
|
|
|
78
104
|
```bash
|
|
79
105
|
git clone https://github.com/AhaiMk01/patchright-cli.git
|
|
80
106
|
cd patchright-cli
|
|
81
107
|
uv venv && uv pip install -e .
|
|
108
|
+
python -m patchright install chromium
|
|
82
109
|
```
|
|
83
110
|
|
|
111
|
+
</details>
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
84
115
|
## Quick Start
|
|
85
116
|
|
|
86
117
|
```bash
|
|
@@ -102,27 +133,39 @@ patchright-cli screenshot
|
|
|
102
133
|
patchright-cli close
|
|
103
134
|
```
|
|
104
135
|
|
|
136
|
+
---
|
|
137
|
+
|
|
105
138
|
## Architecture
|
|
106
139
|
|
|
107
140
|
```mermaid
|
|
108
141
|
graph LR
|
|
109
|
-
A[CLI
|
|
110
|
-
B -->|Patchright
|
|
142
|
+
A[CLI] -->|TCP:9321| B[Daemon]
|
|
143
|
+
B -->|Patchright| C[Chrome]
|
|
111
144
|
```
|
|
112
145
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
146
|
+
| Component | Role |
|
|
147
|
+
|-----------|------|
|
|
148
|
+
| **Daemon** (`daemon.py`) | Long-running process managing browser sessions via Patchright. Auto-starts on first `open`. |
|
|
149
|
+
| **CLI** (`cli.py`) | Thin client — connects, sends command, prints result, disconnects. Browser stays open. |
|
|
150
|
+
| **Snapshot** (`snapshot.py`) | `TreeWalker`-based DOM scan assigning `data-patchright-ref` attributes for element targeting. |
|
|
151
|
+
|
|
152
|
+
---
|
|
116
153
|
|
|
117
|
-
|
|
154
|
+
<details>
|
|
155
|
+
<summary><h2>📖 Commands</h2></summary>
|
|
118
156
|
|
|
119
157
|
### Core
|
|
120
158
|
```bash
|
|
121
159
|
patchright-cli open [url] # Launch browser
|
|
122
160
|
patchright-cli open --persistent # With persistent profile
|
|
161
|
+
patchright-cli open --headless # Run headless
|
|
162
|
+
patchright-cli open --profile=<path> # Custom profile directory
|
|
123
163
|
patchright-cli goto <url> # Navigate
|
|
124
164
|
patchright-cli click <ref> # Click element
|
|
165
|
+
patchright-cli click <ref> right # Right-click
|
|
166
|
+
patchright-cli click <ref> --modifiers=Alt,Shift
|
|
125
167
|
patchright-cli dblclick <ref> # Double-click
|
|
168
|
+
patchright-cli dblclick <ref> --modifiers=Shift
|
|
126
169
|
patchright-cli fill <ref> <value> # Fill text input
|
|
127
170
|
patchright-cli type <text> # Type via keyboard
|
|
128
171
|
patchright-cli hover <ref> # Hover over element
|
|
@@ -133,7 +176,9 @@ patchright-cli drag <from> <to> # Drag and drop
|
|
|
133
176
|
patchright-cli snapshot # Accessibility snapshot
|
|
134
177
|
patchright-cli snapshot --filename=f # Save to custom path
|
|
135
178
|
patchright-cli eval <expr> # Run JavaScript
|
|
136
|
-
patchright-cli
|
|
179
|
+
patchright-cli run-code <code> # Run JS with return value
|
|
180
|
+
patchright-cli screenshot # Page screenshot
|
|
181
|
+
patchright-cli screenshot --full-page # Full scrollable page
|
|
137
182
|
patchright-cli screenshot <ref> # Element screenshot
|
|
138
183
|
patchright-cli screenshot --filename=f # Save to custom path
|
|
139
184
|
patchright-cli close # Close session
|
|
@@ -189,9 +234,11 @@ patchright-cli state-load <file> # Restore saved state
|
|
|
189
234
|
# Cookies
|
|
190
235
|
patchright-cli cookie-list
|
|
191
236
|
patchright-cli cookie-list --domain=example.com
|
|
237
|
+
patchright-cli cookie-list --path=/api
|
|
192
238
|
patchright-cli cookie-get <name>
|
|
193
239
|
patchright-cli cookie-set <name> <value>
|
|
194
240
|
patchright-cli cookie-set <name> <value> --domain=example.com --httpOnly --secure
|
|
241
|
+
patchright-cli cookie-set <name> <value> --path=/ --sameSite=Lax --expires=1735689600
|
|
195
242
|
patchright-cli cookie-delete <name>
|
|
196
243
|
patchright-cli cookie-clear
|
|
197
244
|
|
|
@@ -214,6 +261,9 @@ patchright-cli sessionstorage-clear
|
|
|
214
261
|
```bash
|
|
215
262
|
patchright-cli route "**/*.jpg" --status=404
|
|
216
263
|
patchright-cli route "https://api.example.com/**" --body='{"mock":true}'
|
|
264
|
+
patchright-cli route "**/*" --content-type=application/json --body='{"ok":true}'
|
|
265
|
+
patchright-cli route "**/*" --header=X-Custom:value
|
|
266
|
+
patchright-cli route "**/*" --remove-header=Content-Type
|
|
217
267
|
patchright-cli route-list
|
|
218
268
|
patchright-cli unroute "**/*.jpg"
|
|
219
269
|
patchright-cli unroute # Remove all routes
|
|
@@ -242,8 +292,13 @@ patchright-cli list # List all sessions
|
|
|
242
292
|
patchright-cli close-all
|
|
243
293
|
patchright-cli kill-all
|
|
244
294
|
patchright-cli delete-data # Delete persistent profile
|
|
295
|
+
patchright-cli --port=9322 open # Custom daemon port
|
|
245
296
|
```
|
|
246
297
|
|
|
298
|
+
</details>
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
247
302
|
## Snapshots
|
|
248
303
|
|
|
249
304
|
After each state-changing command, the CLI outputs page info and a YAML snapshot:
|
|
@@ -256,7 +311,7 @@ After each state-changing command, the CLI outputs page info and a YAML snapshot
|
|
|
256
311
|
[Snapshot](.patchright-cli/page-1774376207818.yml)
|
|
257
312
|
```
|
|
258
313
|
|
|
259
|
-
The snapshot lists interactive elements with refs:
|
|
314
|
+
The snapshot lists interactive elements with refs you can use in commands:
|
|
260
315
|
|
|
261
316
|
```yaml
|
|
262
317
|
- ref: e1
|
|
@@ -269,32 +324,44 @@ The snapshot lists interactive elements with refs:
|
|
|
269
324
|
url: "https://iana.org/domains/example"
|
|
270
325
|
```
|
|
271
326
|
|
|
272
|
-
|
|
327
|
+
> [!NOTE]
|
|
328
|
+
> Use refs directly: `patchright-cli click e2`, `patchright-cli fill e5 "text"`
|
|
329
|
+
|
|
330
|
+
---
|
|
273
331
|
|
|
274
332
|
## Anti-Detect Features
|
|
275
333
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
- Persistent profiles maintain cookies/sessions across runs
|
|
279
|
-
- No custom user-agent or headers (natural fingerprint)
|
|
280
|
-
- Headed by default (headless is more detectable)
|
|
334
|
+
> [!CAUTION]
|
|
335
|
+
> This tool is for **authorized testing, security research, and legitimate automation** only.
|
|
281
336
|
|
|
282
|
-
|
|
337
|
+
- :white_check_mark: Real Chrome browser (not Chromium)
|
|
338
|
+
- :white_check_mark: Patchright patches `navigator.webdriver` and other detection vectors
|
|
339
|
+
- :white_check_mark: Persistent profiles maintain cookies/sessions across runs
|
|
340
|
+
- :white_check_mark: No custom user-agent or headers (natural fingerprint)
|
|
341
|
+
- :white_check_mark: Headed by default (headless is more detectable)
|
|
283
342
|
|
|
284
|
-
|
|
343
|
+
---
|
|
285
344
|
|
|
286
|
-
|
|
287
|
-
cp -r skills/patchright-cli ~/.claude/skills/
|
|
288
|
-
```
|
|
345
|
+
## Agent Integration
|
|
289
346
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
patchright-cli
|
|
295
|
-
patchright-cli
|
|
296
|
-
patchright-cli
|
|
297
|
-
|
|
347
|
+
Works with any AI coding agent that supports SKILL.md skills:
|
|
348
|
+
|
|
349
|
+
| Agent | Install skill |
|
|
350
|
+
|-------|--------------|
|
|
351
|
+
| **Claude Code** | `mkdir -p ~/.claude/skills/patchright-cli && curl -sL https://raw.githubusercontent.com/AhaiMk01/patchright-cli/main/skills/patchright-cli/SKILL.md -o ~/.claude/skills/patchright-cli/SKILL.md` |
|
|
352
|
+
| **OpenClaw** | `mkdir -p ~/.openclaw/skills/patchright-cli && curl -sL https://raw.githubusercontent.com/AhaiMk01/patchright-cli/main/skills/patchright-cli/SKILL.md -o ~/.openclaw/skills/patchright-cli/SKILL.md` |
|
|
353
|
+
| **Codex CLI** | `mkdir -p ~/.codex/skills/patchright-cli && curl -sL https://raw.githubusercontent.com/AhaiMk01/patchright-cli/main/skills/patchright-cli/SKILL.md -o ~/.codex/skills/patchright-cli/SKILL.md` |
|
|
354
|
+
| **Gemini CLI** | `mkdir -p ~/.gemini/skills/patchright-cli && curl -sL https://raw.githubusercontent.com/AhaiMk01/patchright-cli/main/skills/patchright-cli/SKILL.md -o ~/.gemini/skills/patchright-cli/SKILL.md` |
|
|
355
|
+
| **OpenCode** | `mkdir -p ~/.opencode/skills/patchright-cli && curl -sL https://raw.githubusercontent.com/AhaiMk01/patchright-cli/main/skills/patchright-cli/SKILL.md -o ~/.opencode/skills/patchright-cli/SKILL.md` |
|
|
356
|
+
| **Cursor** | Copy SKILL.md to `.cursor/skills/patchright-cli/` in your project |
|
|
357
|
+
| **Windsurf** | Copy SKILL.md to `.windsurf/skills/patchright-cli/` in your project |
|
|
358
|
+
| **Aider** | Copy SKILL.md to `.aider/skills/patchright-cli/` in your project |
|
|
359
|
+
|
|
360
|
+
Or just tell your agent:
|
|
361
|
+
|
|
362
|
+
> Install patchright-cli skill from https://raw.githubusercontent.com/AhaiMk01/patchright-cli/main/skills/patchright-cli/SKILL.md
|
|
363
|
+
|
|
364
|
+
---
|
|
298
365
|
|
|
299
366
|
## Star History
|
|
300
367
|
|
|
@@ -306,6 +373,34 @@ patchright-cli click e5
|
|
|
306
373
|
</picture>
|
|
307
374
|
</a>
|
|
308
375
|
|
|
376
|
+
---
|
|
377
|
+
|
|
378
|
+
<details>
|
|
379
|
+
<summary><h2>Differences from playwright-cli</h2></summary>
|
|
380
|
+
|
|
381
|
+
patchright-cli aims for full command parity with [Microsoft's playwright-cli](https://github.com/microsoft/playwright-cli). The following playwright-cli features are **intentionally not implemented** due to Patchright's architecture:
|
|
382
|
+
|
|
383
|
+
| Feature | Reason |
|
|
384
|
+
|---------|--------|
|
|
385
|
+
| `--browser=firefox/webkit/msedge` | Patchright only supports Chromium/Chrome. Anti-detect patches are Chrome-specific. |
|
|
386
|
+
| `--config=<file>` | No config file system. Options are passed as CLI flags. |
|
|
387
|
+
| `--extension` | Browser extension connection not supported. Patchright uses CDP directly. |
|
|
388
|
+
| `show` / `devtools-start` | DevTools are available natively in headed mode (default). |
|
|
389
|
+
| `install` / `install-browser` | Use `python -m patchright install chromium` instead. |
|
|
390
|
+
|
|
391
|
+
All other commands and options are fully supported.
|
|
392
|
+
|
|
393
|
+
</details>
|
|
394
|
+
|
|
395
|
+
---
|
|
396
|
+
|
|
397
|
+
## Disclaimer
|
|
398
|
+
|
|
399
|
+
> [!WARNING]
|
|
400
|
+
> This tool is provided for **authorized security testing, legitimate automation, and educational purposes** only. Users are solely responsible for ensuring their use complies with applicable laws and the terms of service of any websites they interact with. The authors do not endorse or encourage any unauthorized access, scraping, or circumvention of security measures. Use at your own risk.
|
|
401
|
+
|
|
402
|
+
---
|
|
403
|
+
|
|
309
404
|
## License
|
|
310
405
|
|
|
311
406
|
Apache 2.0 — same as [playwright-cli](https://github.com/microsoft/playwright-cli)
|