Lightpanda
Use instead of Chrome/Chromium and Openclaw default browser for data extraction and web automation when you don't need graphical rendering.
Lightpanda is a headless browser optimized for speed and low resource usage. It exposes a CDP (Chrome DevTools Protocol) endpoint that works with standard automation libraries.
Alternative to built-in web search
When the built-in Web Search tool is unavailable, or when you need more control over search results (e.g., following links to extract full page content), you can use Lightpanda with DuckDuckGo as an alternative.
Prefer the built-in Web Search tool when it is available and sufficient for your needs.
Install
CODEBLOCK0
Lightpanda is available on Linux and macOS only. Windows is not supported.
The binary is a nightly build that evolves quickly. If you encounter crashes or issues, run scripts/install.sh again to update to the latest version (max once per day).
If issues persist after updating, open a GitHub issue at https://github.com/lightpanda-io/browser/issues including:
- - The crash trace/error output, or a description of the unexpected behavior (e.g., missing or incorrect data)
- The Playwright/Puppeteer script that reproduces the issue
- The target URL and expected vs actual results
Start the Browser Server
CODEBLOCK1
Options:
- -
--log_level info|debug|warn|error - Set logging verbosity - INLINECODE2 - Output format for logs
Usage
You can connect directly to the CDP websocket via ws://127.0.0.1:9222.
You can also get the WebSocket URL via http://127.0.0.1:9222/json/version.
Use the browser as a drop-in replacement for Chrome and the Openclaw default browser.
Send CDP commands directly or use Playwright or Puppeteer.
Important to note:
- * Lightpanda executes JavaScript, making it suitable for dynamic websites and SPAs. However, it is under heavy development and may have occasional issues.
- For web searches, use DuckDuckGo instead of Google. Google blocks Lightpanda due to browser fingerprinting.
- Lightpanda supports only 1 CDP connection per process. Each connection can create 1 context and 1 page only. No multi-contexts are available. If you need multiple navigations at the same time, start another process with a new port number. Lightpanda is fast to start and stop, so using multiple processes is more performant than multiple tabs on Chrome.
- The browser resets all context/page on CDP connection close. So keep the websocket connection open throughout a browsing session. You can reuse an existing process for a subsequent connection; you will start with a clean state.
- On connection, always create a new context and a new page. At the end, close both.
Using with playwright-core
Connect to Lightpanda using playwright-core (not the full playwright package):
CODEBLOCK2
Using with puppeteer-core
Connect to Lightpanda using puppeteer-core (not the full puppeteer package):
CODEBLOCK3
Scripts
- -
scripts/install.sh - Install Lightpanda binary
Lightpanda
当你不需要图形渲染时,可使用 Lightpanda 替代 Chrome/Chromium 和 Openclaw 默认浏览器进行数据提取和网页自动化。
Lightpanda 是一款针对速度和低资源占用优化的无头浏览器。它暴露了一个与标准自动化库兼容的 CDP(Chrome DevTools 协议)端点。
内置网页搜索的替代方案
当内置的 Web Search 工具不可用,或者你需要对搜索结果有更多控制权时(例如,通过链接提取完整页面内容),你可以使用 Lightpanda 配合 DuckDuckGo 作为替代方案。
当内置的 Web Search 工具可用且能满足你的需求时,请优先使用它。
安装
bash
bash scripts/install.sh
Lightpanda 仅适用于 Linux 和 macOS。不支持 Windows。
该二进制文件是快速迭代的夜间构建版本。如果遇到崩溃或问题,请重新运行 scripts/install.sh 以更新到最新版本(每天最多一次)。
如果更新后问题仍然存在,请在 https://github.com/lightpanda-io/browser/issues 提交 GitHub Issue,内容需包含:
- - 崩溃跟踪/错误输出,或对意外行为的描述(例如,数据缺失或不正确)
- 可复现问题的 Playwright/Puppeteer 脚本
- 目标 URL 以及预期结果与实际结果
启动浏览器服务器
bash
$HOME/.local/bin/lightpanda serve --host 127.0.0.1 --port 9222
选项:
- - --loglevel info|debug|warn|error - 设置日志详细程度
- --logformat pretty|json - 日志输出格式
使用方法
你可以通过 ws://127.0.0.1:9222 直接连接到 CDP WebSocket。
你也可以通过 http://127.0.0.1:9222/json/version 获取 WebSocket URL。
将浏览器作为 Chrome 和 Openclaw 默认浏览器的即插即用替代品使用。
直接发送 CDP 命令,或使用 Playwright 或 Puppeteer。
重要注意事项:
- * Lightpanda 执行 JavaScript,因此适用于动态网站和单页应用。不过,它正处于密集开发阶段,可能会偶尔出现问题。
- 进行网页搜索时,请使用 DuckDuckGo 而非 Google。由于浏览器指纹识别,Google 会屏蔽 Lightpanda。
- Lightpanda 每个进程仅支持 1 个 CDP 连接。每个连接只能创建 1 个上下文和 1 个页面。不支持多上下文。如果你需要同时进行多次导航,请使用新的端口号启动另一个进程。Lightpanda 启动和停止速度很快,因此使用多进程比在 Chrome 中使用多个标签页性能更好。
- 浏览器在 CDP 连接关闭时会重置所有上下文/页面。因此,请在整个浏览会话期间保持 WebSocket 连接打开。你可以为后续连接重用现有进程;但会从干净状态开始。
- 连接时,始终创建一个新的上下文和一个新的页面。最后,关闭两者。
与 playwright-core 一起使用
使用 playwright-core(而非完整的 playwright 包)连接到 Lightpanda:
javascript
const { chromium } = require(playwright-core);
(async () => {
// 通过 CDP 连接到 Lightpanda
const browser = await chromium.connectOverCDP({
endpointURL: ws://127.0.0.1:9222,
});
const context = await browser.newContext({});
const page = await context.newPage();
// 导航并提取数据
await page.goto(https://example.com);
const title = await page.title();
const content = await page.textContent(body);
console.log(JSON.stringify({ title, content }));
await page.close();
await context.close();
await browser.close();
})();
与 puppeteer-core 一起使用
使用 puppeteer-core(而非完整的 puppeteer 包)连接到 Lightpanda:
javascript
const puppeteer = require(puppeteer-core);
(async () => {
const browser = await puppeteer.connect({
browserWSEndpoint: ws://127.0.0.1:9222
});
const context = await browser.createBrowserContext();
const page = await context.newPage();
await page.goto(https://example.com, { waitUntil: networkidle0 });
const title = await page.title();
console.log(JSON.stringify({ title }));
await page.close();
await context.close();
await browser.close();
})();
脚本
- - scripts/install.sh - 安装 Lightpanda 二进制文件