A powerful CLI for DrissionPage — browser automation, structured data extraction, network listening and more.
Project description
dp-cli
A powerful CLI for DrissionPage — browser automation, structured data extraction, network listening and more.
Features
- Anti-detection by default — not based on webdriver,
navigator.webdriverisfalse - Reuse your own browser — connect to a running Chrome via
--port, keeping login state and cookies - Powerful locator syntax — descriptive strings stable across navigation (no ephemeral refs)
- Structured data extraction —
extract+query+snapshot --mode contentfor scraping list pages - Network listening — capture XHR/Fetch requests and response bodies
- Dual mode — browser control + pure HTTP requests
- Shadow-root / iframe — traverse directly without switching context
- JSON output — all commands output JSON, AI-friendly
Installation
pip install dp-cli
dp --help
Quick Start
# Auto-managed browser
dp open https://example.com
dp snapshot
dp click "text:Login"
dp fill "@name=username" admin
dp press Enter
dp close
# Connect to your own logged-in browser
google-chrome --remote-debugging-port=9222
dp open https://example.com --port 9222
dp snapshot
Data Extraction (3-step workflow)
# 1. Discover CSS class names via noise-filtered content tree
dp snapshot --mode content --max-text 40
# 2. Verify field selectors
dp query "css:.item-title" --fields "text,loc"
# 3. Batch extract to CSV
dp extract "css:.item-card" \
'{"title":"css:.item-title",
"price":"css:.item-price",
"tags":{"selector":"css:.tag","multi":true},
"url":{"selector":"css:a","attr":"href"}}' \
--limit 100 --output csv --filename result.csv
Project Structure
dp_cli/
├── main.py # CLI entry point (~47 lines)
├── session.py # Browser session management
├── snapshot.py # Page snapshot & data extraction engine
├── output.py # JSON output helpers
└── commands/
├── _utils.py # Shared decorators & helpers
├── browser.py # open / goto / reload / close / list
├── snapshot_cmd.py # snapshot / extract / query / find / inspect
├── element.py # click / fill / select / hover / drag / check / upload
├── keyboard.py # press / type / scroll / scroll-to
├── page.py # screenshot / pdf / eval / wait / dialog
├── tab.py # tab-list / tab-new / tab-select / tab-close
├── storage.py # cookie-* / localstorage-* / sessionstorage-*
├── network.py # listen / listen-stop / http-get / http-post
└── misc.py # resize / maximize / state-save / state-load / config-set
Documentation
See skills/SKILL.md for full workflow guide and skills/references/commands.md for complete command reference.
License
BSD-3-Clause
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 dp_cli-0.1.0.tar.gz.
File metadata
- Download URL: dp_cli-0.1.0.tar.gz
- Upload date:
- Size: 36.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
703782fdaf9aa76c059e99d74670547e8f054848f728a920deba90e03f022900
|
|
| MD5 |
3bcc2a9600a8b1e25ecffb624cf8911d
|
|
| BLAKE2b-256 |
c961b11ebabbefb16a9e73ee7ed8537a4bf83b77d7a5cf7b9de7e9883a7e2e3c
|
File details
Details for the file dp_cli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dp_cli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 43.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b81e5d895cb51da2a7039869da30213d5c0a78222677a3420bfa3ae2f623a471
|
|
| MD5 |
d9d6a03c1fa8b4cee36e266205a31db9
|
|
| BLAKE2b-256 |
4d4506ed720d641cc319b52ff23cf108b0bda9a043d3127bac7661fcf37d686a
|