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.1.tar.gz (36.5 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.1-py3-none-any.whl (43.9 kB view details)

Uploaded Python 3

File details

Details for the file dp_cli-0.1.1.tar.gz.

File metadata

  • Download URL: dp_cli-0.1.1.tar.gz
  • Upload date:
  • Size: 36.5 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.1.tar.gz
Algorithm Hash digest
SHA256 abd370370e73cb07b4091888fa4463d45750aa42a50ab706f0b5fd45a2edea9b
MD5 d00161366c8bd57726f1c9bc5a60680f
BLAKE2b-256 0c3f4e5ba4e29f25f61501eb45cce01e8ac0bdabcf7b78fe38b0b6db97b199e2

See more details on using hashes here.

File details

Details for the file dp_cli-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: dp_cli-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 43.9 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d170607e8dca04f322720629d9f739b85736155ec74fff318e478cf3f4e04e6e
MD5 2d4f07646e40647669ec9aa9f72a1605
BLAKE2b-256 227ca78a74e136988ea2c8d249a258baa5844e42d6515a3b756169c549020f63

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