mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-07-31 09:46:05 -04:00
PR_SET_PDEATHSIG on the spawned lightpanda mcp process (Linux) so a SIGKILLed or crashed interpreter cannot leak a browser process — a 2h44m orphan surfaced during the v6 benchmark campaign. Regression test kills a parent and asserts the sidecar exits.
lightpanda for Python
Scrape and automate the web from Python with the Lightpanda headless browser — an order of magnitude lighter than Chrome. The wheel bundles the browser binary; there is no separate install step.
from lightpanda import Browser
with Browser() as b:
page = b.new_session()
page.goto(url="https://example.com")
data = page.extract(schema={"title": "h1"})
Every browser tool is a Session method (both waitForSelector and
wait_for_selector work), with kwargs matching the tool's documented
arguments. Replay a saved lightpanda agent script without any LLM:
from lightpanda import run_script
run_script("hn.lp.js", env={"LP_HN_USERNAME": "me"})
The package also puts the full lightpanda CLI on PATH (agent REPL, fetch,
serve).
Development
The runtime binary is resolved from LIGHTPANDA_BIN, the package directory,
then PATH. For a repo checkout: build with zig build and run tests with
uv run --group dev pytest tests
Regenerate the tool methods (lightpanda/_methods.py) and the API docs:
uv run --no-project python scripts/generate_methods.py
uv run --no-project --with pdoc python scripts/build_docs.py # writes docs/