Expand description
Lightweight browser automation for Starpod via Chrome DevTools Protocol.
This crate provides BrowserSession, a high-level async interface for
controlling a CDP-speaking browser (Lightpanda or headless Chromium). It
uses direct CDP over WebSocket and handles process lifecycle, connection
management, and common browser operations.
§Architecture
┌────────────────────┐ CDP/WebSocket ┌──────────────────────┐
│ BrowserSession │ ◄──────────────────── │ lightpanda serve │
│ (async-tungstenite)│ │ (auto-spawned) │
└────────────────────┘ └──────────────────────┘§Usage modes
-
Auto-spawn (recommended):
BrowserSession::launch()finds a free port, spawnslightpanda serve, waits for CDP readiness, and connects. The process is killed onclose()orDrop. -
External:
BrowserSession::connect()attaches to a pre-existing CDP endpoint (e.g. headless Chromium started by the user or systemd).
§Requirements
For auto-spawn mode, lightpanda is automatically downloaded and installed
to ~/.local/bin/ if not already on PATH. No manual setup is needed.
§Example
use starpod_browser::BrowserSession;
// Auto-spawn Lightpanda and navigate
let session = BrowserSession::launch().await?;
let title = session.navigate("https://example.com").await?;
println!("Page title: {title}");
// Extract page text
let text = session.extract(None).await?;
println!("Page text: {text}");
// Clean up
session.close().await?;Structs§
- Browser
Session - A browser automation session backed by CDP.
Enums§
- Browser
Error - Errors from browser operations.
Type Aliases§
- Result
- Convenience alias for
Result<T, BrowserError>.