drissionpage-cli 0.2.0__tar.gz → 0.4.1__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.
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/PKG-INFO +68 -10
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/README.md +63 -6
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/drissionpage_cli/__init__.py +326 -172
- drissionpage_cli-0.4.1/drissionpage_cli/_compat.py +47 -0
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/drissionpage_cli/_feishu.py +42 -2
- drissionpage_cli-0.4.1/drissionpage_cli/_xiaohongshu.py +362 -0
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/drissionpage_cli/skills/drissionpage-cli/SKILL.md +109 -28
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/drissionpage_cli/skills/drissionpage-cli/references/dual-mode.md +8 -12
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/drissionpage_cli/skills/drissionpage-cli/references/network-listening.md +11 -6
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/drissionpage_cli/skills/drissionpage-cli/references/running-code.md +3 -1
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/drissionpage_cli.egg-info/PKG-INFO +68 -10
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/drissionpage_cli.egg-info/SOURCES.txt +2 -0
- drissionpage_cli-0.4.1/drissionpage_cli.egg-info/requires.txt +2 -0
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/pyproject.toml +5 -4
- drissionpage_cli-0.4.1/tests/test_dp5_integration.py +109 -0
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/tests/test_unit.py +129 -13
- drissionpage_cli-0.2.0/drissionpage_cli/_compat.py +0 -105
- drissionpage_cli-0.2.0/drissionpage_cli.egg-info/requires.txt +0 -1
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/LICENSE +0 -0
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/drissionpage_cli/__main__.py +0 -0
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/drissionpage_cli/skills/drissionpage-cli/references/element-locators.md +0 -0
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/drissionpage_cli/skills/drissionpage-cli/references/screenshots-pdf.md +0 -0
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/drissionpage_cli/skills/drissionpage-cli/references/session-management.md +0 -0
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/drissionpage_cli/skills/drissionpage-cli/references/storage-state.md +0 -0
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/drissionpage_cli.egg-info/dependency_links.txt +0 -0
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/drissionpage_cli.egg-info/entry_points.txt +0 -0
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/drissionpage_cli.egg-info/top_level.txt +0 -0
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/setup.cfg +0 -0
- {drissionpage_cli-0.2.0 → drissionpage_cli-0.4.1}/tests/test_integration.py +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: drissionpage-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: DrissionPage CLI - Token-efficient browser automation for coding agents
|
|
5
5
|
Author: DrissionPage-MCP Contributors
|
|
6
6
|
License: Apache-2.0
|
|
7
|
-
Project-URL: Homepage, https://github.com/
|
|
8
|
-
Project-URL: Repository, https://github.com/
|
|
7
|
+
Project-URL: Homepage, https://github.com/M4rque2/DrissionPage-cli
|
|
8
|
+
Project-URL: Repository, https://github.com/M4rque2/DrissionPage-cli
|
|
9
9
|
Keywords: browser,automation,cli,drissionpage,web,scraping
|
|
10
10
|
Classifier: Development Status :: 3 - Alpha
|
|
11
11
|
Classifier: Intended Audience :: Developers
|
|
@@ -21,7 +21,8 @@ Classifier: Topic :: Internet :: WWW/HTTP :: Browsers
|
|
|
21
21
|
Requires-Python: >=3.8
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
23
|
License-File: LICENSE
|
|
24
|
-
Requires-Dist: DrissionPage
|
|
24
|
+
Requires-Dist: DrissionPage<6,>=5.0.0b1
|
|
25
|
+
Requires-Dist: packaging>=21.0
|
|
25
26
|
Dynamic: license-file
|
|
26
27
|
|
|
27
28
|
# DrissionPage-cli
|
|
@@ -58,6 +59,19 @@ Modern coding agents (Claude Code, GitHub Copilot, etc.) increasingly favour CLI
|
|
|
58
59
|
|
|
59
60
|
- Python 3.8+
|
|
60
61
|
- Chrome / Chromium browser installed
|
|
62
|
+
- DrissionPage 5 (`>=5.0.0b1,<6`, installed automatically)
|
|
63
|
+
|
|
64
|
+
### Upgrading from DrissionPage 4
|
|
65
|
+
|
|
66
|
+
This CLI only supports DrissionPage 5. Commands fail before connecting to or launching a browser if an older, unsupported, or unknown version is detected, and print an upgrade command:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
python -m pip install --upgrade --pre "DrissionPage>=5.0.0b1,<6"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The check applies regardless of Chrome's version and cannot be disabled with `DRISSIONPAGE_CLI_NO_VERSION_WARN`. Help, version information, and `install --skills` remain available for recovery.
|
|
73
|
+
|
|
74
|
+
DrissionPage 5 removes `ChromiumPage` and `WebPage`. The CLI uses `Chromium` for browser management and `ChromiumTab` for page operations. See the [official 5.0 changes](https://drissionpage.cn/features/5/) and [Chrome target investigation](docs/chrome146_compatibility_fix.md).
|
|
61
75
|
|
|
62
76
|
## Installation
|
|
63
77
|
|
|
@@ -70,8 +84,8 @@ pip install drissionpage-cli
|
|
|
70
84
|
### From source (development)
|
|
71
85
|
|
|
72
86
|
```bash
|
|
73
|
-
git clone https://github.com/
|
|
74
|
-
cd DrissionPage-
|
|
87
|
+
git clone https://github.com/M4rque2/DrissionPage-cli.git
|
|
88
|
+
cd DrissionPage-cli
|
|
75
89
|
pip install -e .
|
|
76
90
|
```
|
|
77
91
|
|
|
@@ -172,17 +186,28 @@ For a fully isolated throwaway session (no persistent state):
|
|
|
172
186
|
drissionpage-cli open --sandbox
|
|
173
187
|
```
|
|
174
188
|
|
|
175
|
-
### Capture mode (
|
|
189
|
+
### Capture mode (network traffic recording)
|
|
190
|
+
|
|
191
|
+
Append `--capture` to any interaction command to record all network traffic triggered by that action:
|
|
176
192
|
|
|
177
193
|
```bash
|
|
194
|
+
# Capture during navigation
|
|
178
195
|
drissionpage-cli open https://example.com --capture
|
|
196
|
+
drissionpage-cli goto https://example.com --capture
|
|
197
|
+
|
|
198
|
+
# Capture traffic triggered by a click (e.g. form submit, XHR, SPA navigation)
|
|
199
|
+
drissionpage-cli click "#submit" --capture
|
|
200
|
+
|
|
201
|
+
# Also supported on: dblclick, right-click, type, fill, hover, drag, select, check, uncheck
|
|
202
|
+
drissionpage-cli fill "css:input[name=q]" "search term" --submit --capture
|
|
203
|
+
drissionpage-cli hover "@id=lazy-load-trigger" --capture
|
|
179
204
|
```
|
|
180
205
|
|
|
181
206
|
Creates a timestamped folder `capture-<ts>/` in the current directory containing:
|
|
182
207
|
|
|
183
208
|
| File | Contents |
|
|
184
209
|
|------|----------|
|
|
185
|
-
| `snapshot.html` | Page HTML
|
|
210
|
+
| `snapshot.html` | Page HTML after the action completes |
|
|
186
211
|
| `traffic.json` | Manifest of all requests (url, method, status, content_type, file) |
|
|
187
212
|
| `0001_*.{ext}` … | Every response body saved as an individual file |
|
|
188
213
|
|
|
@@ -213,6 +238,8 @@ Captured file types include: HTML, CSS, JS, JSON, images (jpg, png, webp, gif, s
|
|
|
213
238
|
| `select <ref> <value>` | Select dropdown option |
|
|
214
239
|
| `check <ref>` / `uncheck <ref>` | Check / uncheck a checkbox |
|
|
215
240
|
| `upload <ref> <file>` | Upload a file |
|
|
241
|
+
|
|
242
|
+
All commands above (except `upload`) accept `--capture` to record network traffic triggered by the action.
|
|
216
243
|
| `snapshot [ref] [--filename=f]` | Capture page or element snapshot |
|
|
217
244
|
| `eval <expr> [ref]` | Evaluate JavaScript on page or element |
|
|
218
245
|
| `run-code <code> [--filename=f]` | Run arbitrary DrissionPage Python code |
|
|
@@ -321,9 +348,40 @@ Or set a default session via environment variable:
|
|
|
321
348
|
DRISSIONPAGE_CLI_SESSION=myproject drissionpage-cli open https://example.com
|
|
322
349
|
```
|
|
323
350
|
|
|
351
|
+
## Browser Connection Lifecycle
|
|
352
|
+
|
|
353
|
+
### How `open` connects
|
|
354
|
+
|
|
355
|
+
`open` uses a lazy, connection-first strategy — it never kills a browser it didn't launch:
|
|
356
|
+
|
|
357
|
+
1. **Reconnect to previous session** — if a session record exists in `~/.drissionpage-cli/sessions.json` and the browser is still alive, `open` reconnects to it. It does not kill and relaunch. Calling `open <url>` on a running session simply navigates to the new URL.
|
|
358
|
+
2. **Launch a new browser** — if no session record exists and port 9222 is free, `open` starts a fresh Chrome instance with the CLI-managed profile.
|
|
359
|
+
3. **Adopt an existing browser** — if port 9222 is already occupied (e.g. by an orphaned Chrome from a crashed session, or a manually launched `chrome --remote-debugging-port=9222`), `open` attempts a CDP connection. If it succeeds, the browser is adopted as the current session — no restart needed.
|
|
360
|
+
4. **Report an error** — if the port is occupied by something that isn't a controllable Chrome (e.g. another server), `open` reports a clear error with options (`--port=<other>`, `kill-all`). It never auto-kills the process.
|
|
361
|
+
|
|
362
|
+
### How `close` works
|
|
363
|
+
|
|
364
|
+
`close` only shuts down browsers that have a session record. If you run `close` and there is no matching session in the registry, it prints `"Session 'X' not found. Nothing to close."` — it does not probe the port or kill unknown processes. To forcefully clean up all Chrome instances (including orphans), use `kill-all`.
|
|
365
|
+
|
|
366
|
+
### Two processes controlling the same Chrome
|
|
367
|
+
|
|
368
|
+
Chrome DevTools Protocol (CDP) allows multiple clients to connect simultaneously. If two dp-cli processes (or any two CDP clients) attach to the same Chrome on port 9222:
|
|
369
|
+
|
|
370
|
+
- **Both send commands independently.** Chrome executes them in arrival order with no coordination — navigation, clicks, and JS evaluation from one client can interleave unpredictably with the other.
|
|
371
|
+
- **Both receive all events.** DOM changes, navigations, and network events triggered by one client appear to the other as spontaneous activity.
|
|
372
|
+
- **`close` from either side kills Chrome for both.** CDP's `Browser.close` terminates the entire browser process; the other client's WebSocket disconnects immediately.
|
|
373
|
+
- **Neither client can detect the other.** CDP has no API to list connected clients or receive "another client connected" events.
|
|
374
|
+
|
|
375
|
+
**Recommendation:** avoid sharing a single Chrome instance between concurrent automations. Use named sessions on different ports instead:
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
dp-cli -s=task1 open --port=9222 https://site-a.com
|
|
379
|
+
dp-cli -s=task2 open --port=9223 https://site-b.com
|
|
380
|
+
```
|
|
381
|
+
|
|
324
382
|
## Running Custom Code
|
|
325
383
|
|
|
326
|
-
Execute arbitrary DrissionPage Python code with `run-code`. The `page` variable is the active `
|
|
384
|
+
Execute arbitrary DrissionPage Python code with `run-code`. The `page` variable is the active DrissionPage 5 `ChromiumTab`; `browser` is its `Chromium` instance. Set `result` to output a return value.
|
|
327
385
|
|
|
328
386
|
```bash
|
|
329
387
|
drissionpage-cli run-code "result = page.title"
|
|
@@ -379,7 +437,7 @@ DrissionPage-cli/
|
|
|
379
437
|
network-listening.md
|
|
380
438
|
dual-mode.md
|
|
381
439
|
pyproject.toml # Python packaging
|
|
382
|
-
requirements.txt # DrissionPage>=
|
|
440
|
+
requirements.txt # DrissionPage>=5.0.0b1,<6
|
|
383
441
|
pytest.ini # Test configuration
|
|
384
442
|
README.md
|
|
385
443
|
LICENSE
|
|
@@ -32,6 +32,19 @@ Modern coding agents (Claude Code, GitHub Copilot, etc.) increasingly favour CLI
|
|
|
32
32
|
|
|
33
33
|
- Python 3.8+
|
|
34
34
|
- Chrome / Chromium browser installed
|
|
35
|
+
- DrissionPage 5 (`>=5.0.0b1,<6`, installed automatically)
|
|
36
|
+
|
|
37
|
+
### Upgrading from DrissionPage 4
|
|
38
|
+
|
|
39
|
+
This CLI only supports DrissionPage 5. Commands fail before connecting to or launching a browser if an older, unsupported, or unknown version is detected, and print an upgrade command:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
python -m pip install --upgrade --pre "DrissionPage>=5.0.0b1,<6"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The check applies regardless of Chrome's version and cannot be disabled with `DRISSIONPAGE_CLI_NO_VERSION_WARN`. Help, version information, and `install --skills` remain available for recovery.
|
|
46
|
+
|
|
47
|
+
DrissionPage 5 removes `ChromiumPage` and `WebPage`. The CLI uses `Chromium` for browser management and `ChromiumTab` for page operations. See the [official 5.0 changes](https://drissionpage.cn/features/5/) and [Chrome target investigation](docs/chrome146_compatibility_fix.md).
|
|
35
48
|
|
|
36
49
|
## Installation
|
|
37
50
|
|
|
@@ -44,8 +57,8 @@ pip install drissionpage-cli
|
|
|
44
57
|
### From source (development)
|
|
45
58
|
|
|
46
59
|
```bash
|
|
47
|
-
git clone https://github.com/
|
|
48
|
-
cd DrissionPage-
|
|
60
|
+
git clone https://github.com/M4rque2/DrissionPage-cli.git
|
|
61
|
+
cd DrissionPage-cli
|
|
49
62
|
pip install -e .
|
|
50
63
|
```
|
|
51
64
|
|
|
@@ -146,17 +159,28 @@ For a fully isolated throwaway session (no persistent state):
|
|
|
146
159
|
drissionpage-cli open --sandbox
|
|
147
160
|
```
|
|
148
161
|
|
|
149
|
-
### Capture mode (
|
|
162
|
+
### Capture mode (network traffic recording)
|
|
163
|
+
|
|
164
|
+
Append `--capture` to any interaction command to record all network traffic triggered by that action:
|
|
150
165
|
|
|
151
166
|
```bash
|
|
167
|
+
# Capture during navigation
|
|
152
168
|
drissionpage-cli open https://example.com --capture
|
|
169
|
+
drissionpage-cli goto https://example.com --capture
|
|
170
|
+
|
|
171
|
+
# Capture traffic triggered by a click (e.g. form submit, XHR, SPA navigation)
|
|
172
|
+
drissionpage-cli click "#submit" --capture
|
|
173
|
+
|
|
174
|
+
# Also supported on: dblclick, right-click, type, fill, hover, drag, select, check, uncheck
|
|
175
|
+
drissionpage-cli fill "css:input[name=q]" "search term" --submit --capture
|
|
176
|
+
drissionpage-cli hover "@id=lazy-load-trigger" --capture
|
|
153
177
|
```
|
|
154
178
|
|
|
155
179
|
Creates a timestamped folder `capture-<ts>/` in the current directory containing:
|
|
156
180
|
|
|
157
181
|
| File | Contents |
|
|
158
182
|
|------|----------|
|
|
159
|
-
| `snapshot.html` | Page HTML
|
|
183
|
+
| `snapshot.html` | Page HTML after the action completes |
|
|
160
184
|
| `traffic.json` | Manifest of all requests (url, method, status, content_type, file) |
|
|
161
185
|
| `0001_*.{ext}` … | Every response body saved as an individual file |
|
|
162
186
|
|
|
@@ -187,6 +211,8 @@ Captured file types include: HTML, CSS, JS, JSON, images (jpg, png, webp, gif, s
|
|
|
187
211
|
| `select <ref> <value>` | Select dropdown option |
|
|
188
212
|
| `check <ref>` / `uncheck <ref>` | Check / uncheck a checkbox |
|
|
189
213
|
| `upload <ref> <file>` | Upload a file |
|
|
214
|
+
|
|
215
|
+
All commands above (except `upload`) accept `--capture` to record network traffic triggered by the action.
|
|
190
216
|
| `snapshot [ref] [--filename=f]` | Capture page or element snapshot |
|
|
191
217
|
| `eval <expr> [ref]` | Evaluate JavaScript on page or element |
|
|
192
218
|
| `run-code <code> [--filename=f]` | Run arbitrary DrissionPage Python code |
|
|
@@ -295,9 +321,40 @@ Or set a default session via environment variable:
|
|
|
295
321
|
DRISSIONPAGE_CLI_SESSION=myproject drissionpage-cli open https://example.com
|
|
296
322
|
```
|
|
297
323
|
|
|
324
|
+
## Browser Connection Lifecycle
|
|
325
|
+
|
|
326
|
+
### How `open` connects
|
|
327
|
+
|
|
328
|
+
`open` uses a lazy, connection-first strategy — it never kills a browser it didn't launch:
|
|
329
|
+
|
|
330
|
+
1. **Reconnect to previous session** — if a session record exists in `~/.drissionpage-cli/sessions.json` and the browser is still alive, `open` reconnects to it. It does not kill and relaunch. Calling `open <url>` on a running session simply navigates to the new URL.
|
|
331
|
+
2. **Launch a new browser** — if no session record exists and port 9222 is free, `open` starts a fresh Chrome instance with the CLI-managed profile.
|
|
332
|
+
3. **Adopt an existing browser** — if port 9222 is already occupied (e.g. by an orphaned Chrome from a crashed session, or a manually launched `chrome --remote-debugging-port=9222`), `open` attempts a CDP connection. If it succeeds, the browser is adopted as the current session — no restart needed.
|
|
333
|
+
4. **Report an error** — if the port is occupied by something that isn't a controllable Chrome (e.g. another server), `open` reports a clear error with options (`--port=<other>`, `kill-all`). It never auto-kills the process.
|
|
334
|
+
|
|
335
|
+
### How `close` works
|
|
336
|
+
|
|
337
|
+
`close` only shuts down browsers that have a session record. If you run `close` and there is no matching session in the registry, it prints `"Session 'X' not found. Nothing to close."` — it does not probe the port or kill unknown processes. To forcefully clean up all Chrome instances (including orphans), use `kill-all`.
|
|
338
|
+
|
|
339
|
+
### Two processes controlling the same Chrome
|
|
340
|
+
|
|
341
|
+
Chrome DevTools Protocol (CDP) allows multiple clients to connect simultaneously. If two dp-cli processes (or any two CDP clients) attach to the same Chrome on port 9222:
|
|
342
|
+
|
|
343
|
+
- **Both send commands independently.** Chrome executes them in arrival order with no coordination — navigation, clicks, and JS evaluation from one client can interleave unpredictably with the other.
|
|
344
|
+
- **Both receive all events.** DOM changes, navigations, and network events triggered by one client appear to the other as spontaneous activity.
|
|
345
|
+
- **`close` from either side kills Chrome for both.** CDP's `Browser.close` terminates the entire browser process; the other client's WebSocket disconnects immediately.
|
|
346
|
+
- **Neither client can detect the other.** CDP has no API to list connected clients or receive "another client connected" events.
|
|
347
|
+
|
|
348
|
+
**Recommendation:** avoid sharing a single Chrome instance between concurrent automations. Use named sessions on different ports instead:
|
|
349
|
+
|
|
350
|
+
```bash
|
|
351
|
+
dp-cli -s=task1 open --port=9222 https://site-a.com
|
|
352
|
+
dp-cli -s=task2 open --port=9223 https://site-b.com
|
|
353
|
+
```
|
|
354
|
+
|
|
298
355
|
## Running Custom Code
|
|
299
356
|
|
|
300
|
-
Execute arbitrary DrissionPage Python code with `run-code`. The `page` variable is the active `
|
|
357
|
+
Execute arbitrary DrissionPage Python code with `run-code`. The `page` variable is the active DrissionPage 5 `ChromiumTab`; `browser` is its `Chromium` instance. Set `result` to output a return value.
|
|
301
358
|
|
|
302
359
|
```bash
|
|
303
360
|
drissionpage-cli run-code "result = page.title"
|
|
@@ -353,7 +410,7 @@ DrissionPage-cli/
|
|
|
353
410
|
network-listening.md
|
|
354
411
|
dual-mode.md
|
|
355
412
|
pyproject.toml # Python packaging
|
|
356
|
-
requirements.txt # DrissionPage>=
|
|
413
|
+
requirements.txt # DrissionPage>=5.0.0b1,<6
|
|
357
414
|
pytest.ini # Test configuration
|
|
358
415
|
README.md
|
|
359
416
|
LICENSE
|