Skip to main content

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.webdriver is false
  • 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 extractionextract + query + snapshot --mode content for 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dp_cli-0.1.0.tar.gz (36.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dp_cli-0.1.0-py3-none-any.whl (43.7 kB view details)

Uploaded Python 3

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

Hashes for dp_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 703782fdaf9aa76c059e99d74670547e8f054848f728a920deba90e03f022900
MD5 3bcc2a9600a8b1e25ecffb624cf8911d
BLAKE2b-256 c961b11ebabbefb16a9e73ee7ed8537a4bf83b77d7a5cf7b9de7e9883a7e2e3c

See more details on using hashes here.

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

Hashes for dp_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b81e5d895cb51da2a7039869da30213d5c0a78222677a3420bfa3ae2f623a471
MD5 d9d6a03c1fa8b4cee36e266205a31db9
BLAKE2b-256 4d4506ed720d641cc319b52ff23cf108b0bda9a043d3127bac7661fcf37d686a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page