Skip to main content

Python wrapper for Lightpanda browser with CDP server and Playwright integration for lightweight web scraping and automation

Project description

lightpanda-py

Embedded Lightpanda for Python, a fast headless browser for AI agents and web automation.

Installation

pip install lightpanda-py
# or
uv add lightpanda-py

No extra setup - the Lightpanda binary is bundled in the package.

Usage

Fetch

Spin up an ephemeral browser to fetch a page:

import lightpanda

response = lightpanda.fetch("https://example.com")
print(response.text)

# JSON APIs
response = lightpanda.fetch("https://httpbin.org/ip")
data = response.json()

# Markdown output
response = lightpanda.fetch("https://example.com", dump="markdown")

# Strip JS/CSS from output
response = lightpanda.fetch("https://example.com", strip_mode="js,css")

# Wait for network idle before dump
response = lightpanda.fetch("https://example.com", wait_until="networkidle")

CDP Server

Start a CDP server to use with Playwright, Puppeteer, or any CDP client:

import lightpanda

proc = lightpanda.serve(host="127.0.0.1", port=9222)
# 🐼 Running Lightpanda's CDP server... { pid: 12345 }

# Connect with your favorite CDP client...

proc.kill()

Write browser logs to files:

import lightpanda

stdout = open("lightpanda.out.log", "w")
stderr = open("lightpanda.err.log", "w")

proc = lightpanda.serve(stdout=stdout, stderr=stderr)

proc.kill()

With Playwright:

import lightpanda
from playwright.sync_api import sync_playwright

proc = lightpanda.serve()

with sync_playwright() as p:
    browser = p.chromium.connect_over_cdp("http://127.0.0.1:9222")
    page = browser.new_page()
    page.goto("https://example.com")
    print(page.content())
    browser.close()

proc.kill()

MCP Server

Start a Model Context Protocol server over stdio:

import lightpanda, json

proc = lightpanda.mcp()

proc.stdin.write(b'{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}\n')
proc.stdin.flush()
print(json.loads(proc.stdout.readline()))  # list of available tools

proc.kill()

Version

import lightpanda

print(lightpanda.version())

Development

The bundled Lightpanda browser version is pinned in .browser-version.

Download the pinned browser for local development:

scripts/get-browser

By default this downloads the macOS arm64 binary. To use another asset or browser version:

scripts/get-browser lightpanda-x86_64-linux
scripts/get-browser lightpanda-aarch64-macos 0.2.9

Available raw browser assets:

  • lightpanda-aarch64-macos - macOS arm64
  • lightpanda-x86_64-macos - macOS x86_64
  • lightpanda-aarch64-linux - Linux arm64
  • lightpanda-x86_64-linux - Linux x86_64

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

lightpanda_py-0.2.8-py3-none-manylinux_2_35_x86_64.whl (33.5 MB view details)

Uploaded Python 3manylinux: glibc 2.35+ x86-64

lightpanda_py-0.2.8-py3-none-manylinux_2_35_aarch64.whl (33.2 MB view details)

Uploaded Python 3manylinux: glibc 2.35+ ARM64

lightpanda_py-0.2.8-py3-none-macosx_11_0_arm64.whl (19.1 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file lightpanda_py-0.2.8-py3-none-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for lightpanda_py-0.2.8-py3-none-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 5f4a2a22a3077320861d0bb618f8f57d243e001f09c58dfe06d51c9df65325f2
MD5 43d91dfc009f6afc7d4106079c9218d5
BLAKE2b-256 a9a002b305e1b111ecb81c2997eecc4629bef1fc983ee151bea2dd35327e010f

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightpanda_py-0.2.8-py3-none-manylinux_2_35_x86_64.whl:

Publisher: publish.yml on tclesius/lightpanda-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lightpanda_py-0.2.8-py3-none-manylinux_2_35_aarch64.whl.

File metadata

File hashes

Hashes for lightpanda_py-0.2.8-py3-none-manylinux_2_35_aarch64.whl
Algorithm Hash digest
SHA256 93d1e6692d9713b2991260206bfe70a0321400b119673c5cf3a34605081e5dff
MD5 026691ceed9ddedf3a5f994b628dccfd
BLAKE2b-256 5c6b1047f2b7c25edf9d743ea9c2fce346a925d7265938a4e1bf797c3f50d0f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightpanda_py-0.2.8-py3-none-manylinux_2_35_aarch64.whl:

Publisher: publish.yml on tclesius/lightpanda-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lightpanda_py-0.2.8-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lightpanda_py-0.2.8-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9a872b0e480124d773e66794e31bd6e4fe4170c1155d4b82c60fe48ab3ad1534
MD5 1f5f3edcc93acb2acd2c313db7fcd857
BLAKE2b-256 bbaca320086d627ab7c87d96f1c3bbf7e5865baaccba285aaa5a71a2690449d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightpanda_py-0.2.8-py3-none-macosx_11_0_arm64.whl:

Publisher: publish.yml on tclesius/lightpanda-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page