用途 Lightpanda 是一款专为 AI 智能体、网页抓取与自动化设计的无头浏览器。它使用 Zig 从零编写,不基于 Chromium、Blink 或 WebKit,通过 V8 引擎执行 JavaScript,并兼容 CDP(Chrome DevTools Protocol),可与 Playwright、Puppeteer、chromedp 等现有工具配合使用。相比 Chrome headless,资料称其内存占用约低 9 倍、速度约快 11 倍。
主要能力
- JavaScript 执行(V8)
- CDP 兼容,可被 Playwright、Puppeteer、chromedp 连接控制
- 支持 DOM 树操作与查询、XMLHttpRequest、Fetch API、Cookie 管理、网络拦截、代理
- 通过 --obey_robots 标志遵守 robots.txt
- 提供 fetch 命令(输出渲染后的 HTML)和 serve 命令(启动 CDP 服务器)
- 可通过环境变量 LIGHTPANDA_DISABLE_TELEMETRY=true 退出使用指标收集
使用方式 安装:
- macOS(Apple Silicon):curl -L -o lightpanda https://github.com/lightpanda-io/browser/releases/download/nightly/lightpanda-aarch64-macos && chmod a+x ./lightpanda
- Linux(x86_64):curl -L -o lightpanda https://github.com/lightpanda-io/browser/releases/download/nightly/lightpanda-x86_64-linux && chmod a+x ./lightpanda
- Docker:docker run -d --name lightpanda -p 9222:9222 lightpanda/browser:nightly(支持 amd64 与 arm64)
CLI:
- 抓取页面:./lightpanda fetch --obey_robots --log_format pretty --log_level info https://example.com
- 启动 CDP 服务器:./lightpanda serve --obey_robots --log_format pretty --log_level info --host 127.0.0.1 --port 9222
CLI 标志:--obey_robots、--log_format pretty、--log_level(debug/info/warn/error)、--host、--port、--insecure_disable_tls_host_verification(仅测试用)。
集成方式:资料提供了 Playwright(JavaScript 与 Python)、Puppeteer、Go(chromedp)的连接示例,均通过 CDP 端点 http://127.0.0.1:9222 或 ws://127.0.0.1:9222 连接。
抓取模式:资料给出批量页面抓取与结构化数据提取的代码示例。Docker Compose 可将 Lightpanda 与抓取应用组合,通过 BROWSER_WS_ENDPOINT=ws://lightpanda:9222 连接。
适用场景
- 运行需要浏览网页的 AI 智能体
- 大规模批量抓取,关注内存与 CPU 节省
- 表单自动提交与数据提取
- 资源受限的容器环境
- 需要 CDP 兼容但不需要完整可视化渲染
限制
- 不提供可视化渲染,无法生成像素级截图或 PDF
- Web API 覆盖为部分支持,仍在扩展中
- 处于 Beta 阶段,活跃开发中,Playwright 脚本可能因版本变化而行为不同,建议固定版本或统一使用 nightly
- 许可证为 AGPL-3.0
- 源码构建需要 Zig 0.15.2、Rust、CMake 及系统依赖
- 不支持视觉回归测试或浏览器特定渲染行为测试
更多信息
- GitHub:https://github.com/lightpanda-io/browser
- 运行时 API:https://github.com/lightpanda-io/zig-js-runtime
部分内容(如官方收费、价格、具体平台支持细节)暂未提供。