Skip to main content

Pravda

Pravda is a Python library for durable web evidence capture. It drives a remote Playwright browser to capture rendered HTML, full-page screenshots, and HAR recordings with response bodies, written content-addressed to any fsspec-compatible backend. Captures return immutable Snapshot values; persisting them is the application's policy.

  • Browser: a remote Playwright Chromium WebSocket endpoint.
  • Storage: any fsspec URL (./data, s3://bucket, gs://bucket, …).

Installation

Python 3.12+:

pip install opensanctions-pravda
pip install opensanctions-pravda[unmhtml]  # with standalone HTML derivation

Quick start

Build a Storage once, then a long-lived Pravda over it. Instances are safe to reuse: concurrent captures each open their own connection, and the storage handle reads artifacts back later.

from pravda import Pravda, Storage

storage = Storage.from_url("./data")
pravda = Pravda("ws://localhost:3000", storage)

snapshot = await pravda.capture("https://example.com")
print(snapshot.id, snapshot.http_status, snapshot.rendered_html)

capture() returns a Snapshot with client-minted id and captured_at; artifact fields are storage-relative paths, read back with storage.read_artifact(path). A failed capture is returned with error set, not raised.

Configuration

Pravda(browser_ws_url, storage, *, timeouts):

  • timeouts — wall-clock budgets bounding one capture attempt. Defaults are sensible; see the Timeouts docstring.

Usage

Capture a page

By default Pravda navigates, waits for load, and captures. For custom navigation or interaction, pass an async drive(page, url) callback:

async def drive(page, url):
    await page.goto(url, wait_until="commit")
    await page.wait_for_selector(".results")


snapshot = await pravda.capture("https://example.com", drive=drive)

The callback owns navigation; Pravda owns capture and cleanup. Playwright errors from drive are returned as failed snapshots; other exceptions propagate and capture nothing. Viewer-handled downloads (e.g. PDFs) surface in drive as Playwright's Download is starting; Pravda recovers the body into the HAR.

Derive standalone HTML

path = await snapshot.derive_standalone_html(storage)

Derives a self-contained rendering — stylesheets inlined, images embedded as data URIs, active content sanitized — from the snapshot's stored evidence, stores it like any other artifact, and returns its path. Needs no browser, so it works in any process. Requires the unmhtml extra.

Storage

Artifacts are content-addressed files under the captured page's hostname (example.com/<sha1>.html). The Snapshot records each artifact's path: rendered_html, screenshot, and every HAR response.content._file.

Development

Requires uv and a remote Playwright browser endpoint. Environment variables live in .env, which uv does not read automatically:

uv sync
cp .env.example .env
uv run --env-file .env pytest
uv run ruff check .
uv run ruff format --check .

License

MIT — see LICENSE.

Metadata

Release files for opensanctions-pravda 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opensanctions-pravda 0.9.0
File Size Uploaded Provenance Actions
opensanctions_pravda-0.9.0.tar.gz 11.6 kB With provenance Details for opensanctions_pravda-0.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for opensanctions-pravda 0.9.0
File Interpreter ABI Platform Actions
opensanctions_pravda-0.9.0-py3-none-any.whl Python 3 none any Details for opensanctions_pravda-0.9.0-py3-none-any.whl

Total release size: 26.0 kB

Release files / opensanctions_pravda-0.9.0.tar.gz

Download URL opensanctions_pravda-0.9.0.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ebcad6a35257b4cd0103a1b2764197cff116b96d5f0673473624261119d5f7ce
BLAKE2b-256 checksum
How to use checksums
d6623f55fd852bfb0bd840348da5d60013cfa8c032416e985e9220d58042e530
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Release files / opensanctions_pravda-0.9.0-py3-none-any.whl

Download URL opensanctions_pravda-0.9.0-py3-none-any.whl
Size 14.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ea4da4464fe78c790007baef5176c9ada81273b448211a2cc3662668dd44c43
BLAKE2b-256 checksum
How to use checksums
e8faee67dbb0b1169eb884050299b7aac15ba71aa3b02830fd0b14aa42b5d26a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Security for opensanctions-pravda 0.9.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for opensanctions_pravda-0.9.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page