lightpanda-py
Lightpanda for Python, a fast headless browser for AI agents and web automation. Zero dependencies, browser included.
Fetch pages as HTML, Markdown or structured data, run scripts, let an AI agent browse, or start a CDP server for Playwright and Puppeteer and an MCP server for your agents.
Installation
uv add lightpanda-py
Example usage
import lightpanda
result = lightpanda.fetch("https://example.com", dump="markdown")
print(result.text)
Command line
The bundled browser is also available as the lightpanda command, with telemetry disabled by default:
lightpanda fetch --dump markdown https://example.com
lightpanda serve --host 127.0.0.1 --port 9222
Output formats
import lightpanda
html = lightpanda.fetch("https://example.com").text
markdown = lightpanda.fetch("https://example.com", dump="markdown").text
data = lightpanda.fetch("https://httpbin.org/ip").json()
# JSON-LD, OpenGraph, Twitter card and meta tags
meta = lightpanda.fetch("https://example.com", dump="structured_data").json()
# Text-only rendering as PNG or PDF
png = lightpanda.fetch("https://example.com", dump="png").bytes
Waiting and stripping
import lightpanda
# Wait for network idle, or for an element to appear
lightpanda.fetch("https://example.com", wait_until="networkidle")
lightpanda.fetch("https://example.com", wait_selector="h1", dump_selector="h1")
# Drop scripts and styles, or keep only the main content
lightpanda.fetch("https://example.com", strip_mode=["js", "css"])
lightpanda.fetch("https://example.com", dump="markdown", strip_mode="clutter")
Status and multiple URLs
json=True adds the HTTP status, headers and page diagnostics:
import lightpanda
status = lightpanda.fetch("https://example.com", dump="markdown", json=True).json()
print(status["http_status"], status["content"])
results = lightpanda.fetch(["https://example.com", "https://example.org"], dump="markdown").json()
for result in results["results"]:
print(result["url"], result["http_status"])
Any CLI flag
Underscores become dashes, True adds a bare flag, and lists repeat the flag:
import lightpanda
result = lightpanda.fetch(
"https://example.com",
http_header=["Authorization: Bearer token"], # --http-header ...
user_agent_suffix="my-crawler", # --user-agent-suffix my-crawler
obey_robots=True, # --obey-robots
cookie_jar="cookies.json", # --cookie-jar cookies.json
)
Errors raise lightpanda.Error; its message is the browser's stderr and .code the exit status. Pass fail_on_http_error=True to also raise on HTTP 4xx/5xx.
Using Playwright or Puppeteer
import lightpanda
from playwright.sync_api import sync_playwright
with lightpanda.serve(host="127.0.0.1", port=9222) as cdp, sync_playwright() as p:
browser = p.chromium.connect_over_cdp(cdp.endpoint)
page = browser.new_page()
page.goto("https://example.com")
print(page.content())
browser.close()
import lightpanda
# Write logs to files
server = lightpanda.serve(stdout=open("lightpanda.out.log", "w"), stderr=open("lightpanda.err.log", "w"))
# CDP on / and WebDriver BiDi on /session, same port
server = lightpanda.serve(protocol=["cdp", "webdriver"])
# CDP over a Unix-domain socket instead of TCP
server = lightpanda.serve(unix_socket="/tmp/lightpanda.sock")
Running an MCP server
import lightpanda
with lightpanda.mcp() as mcp:
print(mcp.request("tools/list")) # list of available tools
# Or over HTTP, clients POST JSON-RPC to mcp.endpoint (http://127.0.0.1:8080/mcp)
with lightpanda.mcp(port=8080) as mcp:
...
Scraping examples
Self-contained uv scripts in examples/, no install needed:
hacker_news.py- extract the Hacker News front page into a list of stories with a PandaScriptquotes.py- click through a JavaScript-rendered, paginated site with Playwrightdocs_to_markdown.py- fetch several pages as clean, size-capped Markdown for an LLMask_agent.py- let an AI agent browse a site and answer a question
uv run examples/hacker_news.py
# Or without cloning the repo
uv run https://raw.githubusercontent.com/tclesius/lightpanda-py/main/examples/hacker_news.py
Running tests
The bundled browser version is pinned in .browser-version. Download it for your platform, then run pytest:
scripts/get-browser lightpanda-x86_64-linux
uv run pytest
Available platforms:
lightpanda-aarch64-macos- macOS arm64 (default)lightpanda-x86_64-macos- macOS x86_64lightpanda-aarch64-linux- Linux arm64lightpanda-x86_64-linux- Linux x86_64
License
MIT
Metadata
Release files for lightpanda-py 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| lightpanda_py-0.4.0-py3-none-manylinux_2_38_aarch64.whl | Python 3 | none | Linux glibc 2.38+ ARM64 | Details for lightpanda_py-0.4.0-py3-none-manylinux_2_38_aarch64.whl |
| lightpanda_py-0.4.0-py3-none-manylinux_2_35_x86_64.whl | Python 3 | none | Linux glibc 2.35+ x86-64 | Details for lightpanda_py-0.4.0-py3-none-manylinux_2_35_x86_64.whl |
| lightpanda_py-0.4.0-py3-none-macosx_14_0_x86_64.whl | Python 3 | none | macOS 14.0+ x86-64 | Details for lightpanda_py-0.4.0-py3-none-macosx_14_0_x86_64.whl |
| lightpanda_py-0.4.0-py3-none-macosx_14_0_arm64.whl | Python 3 | none | macOS 14.0+ ARM64 | Details for lightpanda_py-0.4.0-py3-none-macosx_14_0_arm64.whl |
Total release size: 114.9 MB
Release files / lightpanda_py-0.4.0-py3-none-manylinux_2_38_aarch64.whl
| Download URL | lightpanda_py-0.4.0-py3-none-manylinux_2_38_aarch64.whl |
|---|---|
| Size | 27.2 MB |
| Tags | Linux glibc 2.38+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
39c2f96f39a2955e383c02b00854ffb18f370b8089487fff082e4da66856fcec
|
|
BLAKE2b-256 checksum How to use checksums |
f5c98dfd2474165759d86bbab085168cc07d17b1c8e1a30d18c472eda56a6715
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 29, 2026.
Transparency logRelease files / lightpanda_py-0.4.0-py3-none-manylinux_2_35_x86_64.whl
| Download URL | lightpanda_py-0.4.0-py3-none-manylinux_2_35_x86_64.whl |
|---|---|
| Size | 28.6 MB |
| Tags | Linux glibc 2.35+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
334981844b925341b85c3d905cbe246128fee5bba3270ccaa9f5a0af6efd6b60
|
|
BLAKE2b-256 checksum How to use checksums |
68935571702e037cd946521e818443139384bec9c9999d70d375120a78bdb394
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 29, 2026.
Transparency logRelease files / lightpanda_py-0.4.0-py3-none-macosx_14_0_x86_64.whl
| Download URL | lightpanda_py-0.4.0-py3-none-macosx_14_0_x86_64.whl |
|---|---|
| Size | 30.4 MB |
| Tags | Python 3 macOS 14.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
a078f54b855756d98a7e68b545dd02f8769e7b1532e707687155768b0832f6ed
|
|
BLAKE2b-256 checksum How to use checksums |
1fd7b7e07a983754db958e69f8517e7ec04821238249f516d3d94499d94610fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 29, 2026.
Transparency logRelease files / lightpanda_py-0.4.0-py3-none-macosx_14_0_arm64.whl
| Download URL | lightpanda_py-0.4.0-py3-none-macosx_14_0_arm64.whl |
|---|---|
| Size | 28.6 MB |
| Tags | Python 3 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
56e6eae1c92c0859db32c9b7de976732f52be188bc0a2a9dcd38c5d2c47ad575
|
|
BLAKE2b-256 checksum How to use checksums |
4844a4344da0aea3995bb18a5f2ec8609177d674d50ccc166e9283cd47427635
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 29, 2026.
Transparency logSecurity for lightpanda-py 0.4.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
All 4 files in this release have been uploaded with provenance metadata.
Attestation for lightpanda_py-0.4.0-py3-none-manylinux_2_38_aarch64.whl
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 29, 2026.
Transparency logA 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.