ricibrowser
A lightweight two-engine browser automation module built entirely on the Chrome DevTools Protocol (CDP). No Playwright, no Puppeteer, no selenium.
Engines
| Engine | Use case | Technology |
|---|---|---|
| Lightpanda (fast path) | crawl, recon, endpoint discovery, non-JS-heavy targets | Zig-based headless engine, CDP at ws://127.0.0.1:9222 |
| CDP-Chrome (thorough path) | DAST, JS-heavy targets, auth flows, anti-bot | Custom CDP client driving the user's real installed Chrome |
Install
pip install ricibrowser
# For the fast path (optional):
bash scripts/install_lightpanda.sh
lightpanda serve --host 127.0.0.1 --port 9222
# For the thorough path:
# Just have Google Chrome installed on your system.
Quick start
Hybrid page snapshots
CDP-Chrome sessions can expose a bounded accessibility/DOM snapshot with document-bound references for the current page. References are invalidated by full document navigations and same-document URL changes; use a fresh snapshot after either event.
snapshot = await session.accessibility_snapshot(interactive_only=True)
# Use snapshot["nodes"][0]["ref"] with session.act_reference(...)
The snapshot combines the CDP accessibility tree with DOM/ARIA enrichment, including roles, accessible names, disabled/checked state, and selectors where available.
Session.snapshot_current_page() is the supported way to capture the currently
loaded page without navigating. Its Page includes HTTP-status provenance,
document generation, navigation/wait diagnostics, actual stealth configuration,
and serializable capabilities. Page.to_dict()["status"] is "partial" when
the DOM was captured but no HTTP status was observed, and "error" when the
navigation itself reported an error; status code 0 remains the compatible
in-memory marker for unknown status.
page = await session.snapshot_current_page(include_accessibility=True)
print(page.status_source, page.document_generation, page.capabilities)
Engine.capabilities reports the facade's available features. Per-page/session
capabilities are more specific: for example, Lightpanda reports no reliable HTTP
status/final URL and no screenshots, while CDP network capture reports
network_bodies=False.
JavaScript exception surfacing
Runtime.evaluate responses now carry CDP exceptionDetails through
session.last_eval_error — a thrown expression returns None with the
actual JS exception text instead of an unexplained null, so callers can
distinguish "expression threw" from "returned undefined".
Trusted clicks and promise-aware evaluation
Session.click now dispatches a trusted CDP Input.dispatchMouseEvent at
the element's center — React/Vue router buttons that ignore synthetic
el.click() dispatches respond to these. A synthetic-click fallback remains
for hidden or zero-size elements.
evaluate/evaluate_value now set awaitPromise, so expressions like
fetch('/api').then(r => r.text()) resolve to the final body instead of an
opaque {} — no store-then-read workaround needed.
Stealth diagnostics
ricibrowser.stealth_benchmark provides a defensive, local consistency
benchmark for an operator-owned fixture page. It checks observable signals such
as navigator.webdriver, user-agent/client-hint consistency, locale/timezone,
WebGL, canvas/audio stability, plugins, CDP artifacts, and TLS consistency when
the fixture supplies them. The score is a debugging heuristic, not a promise of
invisibility or a vendor bot-detector result. It does not probe third-party
anti-bot systems or attempt to evade them.
import asyncio
from ricibrowser import Engine, EngineConfig
async def main():
engine = Engine(EngineConfig())
# Fast path (Lightpanda) — crawl/recon
page = await engine.fast_browse("https://example.com")
print(f"Title: {page.title}")
print(f"Text: {page.text[:200]}")
print(f"Links: {len(page.links)}")
# Thorough path (CDP-Chrome) — DAST/auth flows
session = await engine.create_session()
await session.navigate("https://example.com/login")
await session.fill("#username", "admin")
await session.fill("#password", "pass")
await session.click("#login-btn")
# Cookies/localStorage are persisted when the Session closes. Stored
# localStorage is installed before application scripts on the next visit.
await session.navigate("https://example.com/dashboard") # authenticated!
# JS evaluation in isolated world (never Runtime.enable on main world)
count = await session.evaluate("document.querySelectorAll('script').length")
# Network metadata capture (opt-in, off by default). Response bodies are
# not captured by this CDP monitor.
engine2 = Engine(EngineConfig(debug_network=True))
session2 = await engine2.create_session()
# ... browse ...
flows = engine2.network.to_dict()
await session.close()
await session2.close()
await engine.close()
await engine2.close()
asyncio.run(main())
Stealth
navigator.webdriversuppressed via--disable-blink-features=AutomationControlled(Blink-level, not JS injection)- Uses the user's real installed Chrome (not bundled Chromium) — TLS/JA3 fingerprint matches a real Chrome release
- Never calls
Runtime.enableon the main world — isolated worlds only Console.enableoff by default — only enabled in explicit debug mode- Debug network archival is off by default. Navigation may still enable the CDP Network domain to observe the main-document status and manage cookies.
Session, persistence, and capture lifecycle
- Every Chrome
Sessionowns a distinct page target. Targets share the owning Engine's Chrome profile and cookie store; separate tabs are not separate browser identities. - Chrome startup/restart is serialized per Engine.
Engine.close()first closes active Sessions, then the owned process and temporary profile. Session.close()captures cookies and the current origin's localStorage, including deletion/empty-state changes, saves the jar, finalizes its network capture, closes its CDP connection, and retires its target.- Cookie-jar saves use a cross-process locked read/merge/write transaction. The
on-disk JSON schema remains
{cookies, storage}. - If cleanup cannot be confirmed,
close()raisesRuntimeErrorand retains ownership handles so cleanup can be retried. Call close methods fromfinally. - Completed debug-network metadata remains available from
engine.network.to_dict()after a Session orfast_browse()finishes. The archive is bounded (default 5,000 flows);network.statsreports drops and active clients. Request/response bodies are not captured.
fast_browse(..., wait_until=..., wait_for=..., timeout=...) forwards these
options to the Chrome fallback. Persistent Session.navigate() accepts the same
wait arguments. domcontentloaded waits for the matching browser event rather
than full load; delayed URL changes use a separate bounded change-detection
window (EngineConfig.url_change_timeout).
Proxy scope
EngineConfig.proxy_url is route-only integration: Chrome receives
--proxy-server, and invalid-certificate handling follows the configured proxy
mode. Ricibrowser does not read MiniProxy SQLite data, perform a proxy health
handshake, or correlate CDP records with proxy flow IDs. Capabilities therefore
report proxy_mode="route_only", not full capture integration. Chrome commonly
bypasses loopback destinations; operator-owned loopback tests can opt in with
extra_chrome_args=["--proxy-bypass-list=<-loopback>"].
Architecture
See ARCHITECTURE.md for the full design.
License
MIT
Metadata
Release files for ricibrowser 0.2.30
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ricibrowser-0.2.30.tar.gz | 124.4 kB | Without provenance | Details for ricibrowser-0.2.30.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ricibrowser-0.2.30-py3-none-any.whl | Python 3 | none | any | Details for ricibrowser-0.2.30-py3-none-any.whl |
Total release size: 221.3 kB
Release files / ricibrowser-0.2.30.tar.gz
| Download URL | ricibrowser-0.2.30.tar.gz |
|---|---|
| Size | 124.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
790292e6b0ad08570c0e4b0629a9bea0ec2c6c678458600a438f20731f2bcca0
|
|
BLAKE2b-256 checksum How to use checksums |
8e9b6a0a893da99ab780403cf87fe6fc7a61ec15a4509ed84e513f82d7f34226
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / ricibrowser-0.2.30-py3-none-any.whl
| Download URL | ricibrowser-0.2.30-py3-none-any.whl |
|---|---|
| Size | 96.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3384c843f0b0f454ee73076a4c1aabf0bbae046fd341613619e690b18a9cde68
|
|
BLAKE2b-256 checksum How to use checksums |
b5d9a478d6cea13dd2b56ace081b02c0234b11d6261ba356730d5aabd6a70348
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for ricibrowser 0.2.30
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.