?一、軟件介紹
文末提供程序和源碼下載
Lightpanda開源瀏覽器:專為 AI 和自動化而設計的無界面瀏覽器;
- Javascript execution Javascript 執行
- Support of Web APIs (partial, WIP)
- 支持 Web API(部分、WIP)
- Compatible with Playwright, Puppeteer through CDP (WIP)
- 通過 CDP (WIP) 與 Playwright、Puppeteer 兼容
Fast web automation for AI agents, LLM training, scraping and testing:
用于 AI 代理、LLM訓練、抓取和測試的快速 Web 自動化:
- Ultra-low memory footprint (9x less than Chrome)
- 超低內存占用(比 Chrome 少 9 倍)
- Exceptionally fast execution (11x faster than Chrome)
- 極快的執行速度(比 Chrome 快 11 倍)
- Instant startup 即時啟動
二、Quick start 快速開始
Install from the nightly builds
從 nightly 版本安裝
You can download the last binary from the nightly builds for Linux x86_64 and MacOS aarch64.
您可以從 Linux x86_64 和 MacOS aarch64 的夜間版本中下載最后一個二進制文件。
For Linux 對于 Linux
curl -L -o lightpanda https://github.com/lightpanda-io/browser/releases/download/nightly/lightpanda-x86_64-linux && \
chmod a+x ./lightpanda
For MacOS 對于 MacOS
curl -L -o lightpanda https://github.com/lightpanda-io/browser/releases/download/nightly/lightpanda-aarch64-macos && \
chmod a+x ./lightpanda
For Windows + WSL2 對于 Windows + WSL2
The Lightpanda browser is compatible to run on windows inside WSL. Follow the Linux instruction for installation from a WSL terminal. It is recommended to install clients like Puppeteer on the Windows host.
Lightpanda 瀏覽器兼容在 WSL 內的 Windows 上運行。按照 Linux 說明從 WSL 終端進行安裝。建議在 Windows 主機上安裝像 Puppeteer 這樣的客戶端。
Dump a URL 轉儲 URL
./lightpanda fetch --dump https://lightpanda.io
info(browser): GET https://lightpanda.io/ http.Status.ok
info(browser): fetch script https://api.website.lightpanda.io/js/script.js: http.Status.ok
info(browser): eval remote https://api.website.lightpanda.io/js/script.js: TypeError: Cannot read properties of undefined (reading 'pushState')
<!DOCTYPE html>
Start a CDP server 啟動 CDP 服務器
./lightpanda serve --host 127.0.0.1 --port 9222
info(websocket): starting blocking worker to listen on 127.0.0.1:9222
info(server): accepting new conn...
Once the CDP server started, you can run a Puppeteer script by configuring the browserWSEndpoint.
CDP 服務器啟動后,您可以通過配置 browserWSEndpoint .
'use strict'
import puppeteer from 'puppeteer-core';
// use browserWSEndpoint to pass the Lightpanda's CDP server address.
const browser = await puppeteer.connect({
? browserWSEndpoint: "ws://127.0.0.1:9222",
});
// The rest of your script remains the same.
const context = await browser.createBrowserContext();
const page = await context.newPage();
// Dump all the links from the page.
await page.goto('https://wikipedia.com/');
const links = await page.evaluate(() => {
? return Array.from(document.querySelectorAll('a')).map(row => {
? ? return row.getAttribute('href');
? });
});
console.log(links);
await page.close();
await context.close();
await browser.disconnect();
Telemetry 遙測
By default, Lightpanda collects and sends usage telemetry. This can be disabled by setting an environment variable LIGHTPANDA_DISABLE_TELEMETRY=true. You can read Lightpanda's privacy policy at: https://lightpanda.io/privacy-policy.
默認情況下,Lightpanda 收集和發送使用情況遙測數據。這可以通過設置 environment variable LIGHTPANDA_DISABLE_TELEMETRY=true 來禁用。您可以在以下網址閱讀 Lightpanda 的隱私政策:https://lightpanda.io/privacy-policy。
三、Build from sources 從源構建
Prerequisites 先決條件
Lightpanda is written with Zig 0.14.0. You have to install it with the right version in order to build the project.
Lightpanda 是用 Zig 0.14.0 編寫的。您必須使用正確的版本安裝它才能構建項目。
Lightpanda also depends on zig-js-runtime (with v8), Netsurf libs and Mimalloc.
Lightpanda 還依賴于 zig-js-runtime(v8)、Netsurf 庫和 Mimalloc。
To be able to build the v8 engine for zig-js-runtime, you have to install some libs:
為了能夠為 zig-js-runtime 構建 v8 引擎,您必須安裝一些庫:
For Debian/Ubuntu based Linux:
對于基于 Debian/Ubuntu 的 Linux:
sudo apt install xz-utils \
? ? python3 ca-certificates git \
? ? pkg-config libglib2.0-dev \
? ? gperf libexpat1-dev \
? ? cmake clang
For systems with Nix, you can use the devShell:
對于帶有 Nix 的系統,你可以使用 devShell:
nix develop
For MacOS, you only need cmake:
對于 MacOS,你只需要 cmake:
brew install cmake
Install and build dependencies
安裝和構建依賴項
All in one build 多合一構建
You can run make install to install deps all in one (or make install-dev if you need the development versions).
您可以運行 make install 以將 deps 全部安裝在一個 (或者 make install-dev 如果您需要開發版本)。
Be aware that the build task is very long and cpu consuming, as you will build from sources all dependencies, including the v8 Javascript engine.
請注意,構建任務非常長且占用大量 CPU,因為您將從源構建所有依賴項,包括 v8 Javascript 引擎。
Step by step build dependency
逐步構建依賴項
The project uses git submodules for dependencies.
該項目使用 git submodules 作為依賴項。
To init or update the submodules in the vendor/ directory:
要初始化或更新目錄中的 vendor/ 子模塊,請執行以下作:
make install-submodule
iconv 圖標
libiconv is an internationalization library used by Netsurf.
libiconv 是 Netsurf 使用的國際化庫。
make install-libiconv
Netsurf libs Netsurf 庫
Netsurf libs are used for HTML parsing and DOM tree generation.
Netsurf 庫用于 HTML 解析和 DOM 樹生成。
make install-netsurf
For dev env, use make install-netsurf-dev.
對于 dev env,請使用 make install-netsurf-dev .
Mimalloc
Mimalloc is used as a C memory allocator.
Mimalloc 用作 C 內存分配器。
make install-mimalloc
For dev env, use make install-mimalloc-dev.
對于 dev env,請使用 make install-mimalloc-dev .
Note: when Mimalloc is built in dev mode, you can dump memory stats with the env var MIMALLOC_SHOW_STATS=1. See https://microsoft.github.io/mimalloc/environment.html.
注意:當 Mimalloc 在 dev 模式下構建時,您可以使用 env var 轉儲內存統計信息 MIMALLOC_SHOW_STATS=1 。請參閱 https://microsoft.github.io/mimalloc/environment.html。
v8
First, get the tools necessary for building V8, as well as the V8 source code:
首先,獲取構建 V8 所需的工具以及 V8 源代碼:
make get-v8
Next, build v8. This build task is very long and cpu consuming, as you will build v8 from sources.
接下來,構建 v8。此構建任務非常長且占用 CPU,因為您將從源代碼構建 v8。
make build-v8
For dev env, use make build-v8-dev.
對于 dev env,請使用 make build-v8-dev .
四、Test 測試
Unit Tests 單元測試
You can test Lightpanda by running make test.
您可以通過運行 make test 來測試 Lightpanda。
End to end tests 端到端測試
To run end to end tests, you need to clone the demo repository into ../demo dir.
要運行端到端測試,您需要將 demo 存儲庫克隆到 dir 中 ../demo 。
You have to install the demo's node requirements
您必須安裝 demo 的 node 要求
You also need to install Go > v1.24.
您還需要安裝 Go > v1.24。
make end2end
Web Platform Tests Web 平臺測試
Lightpanda is tested against the standardized Web Platform Tests.
Lightpanda 已針對標準化 Web 平臺測試進行了測試。
The relevant tests cases are committed in a dedicated repository which is fetched by the make install-submodule command.
相關測試用例提交到由 make install-submodule 命令獲取的專用存儲庫中。
All the tests cases executed are located in the tests/wpt sub-directory.
執行的所有測試用例都位于 tests/wpt 子目錄中。
For reference, you can easily execute a WPT test case with your browser via wpt.live.
作為參考,您可以通過 wpt.live 使用瀏覽器輕松執行 WPT 測試用例。
Run WPT test suite 運行 WPT 測試套件
To run all the tests:
要運行所有測試,請執行以下作:
make wpt
Or one specific test:
或一個特定的測試:
make wpt Node-childNodes.html
Add a new WPT test case
添加新的 WPT 測試用例
We add new relevant tests cases files when we implemented changes in Lightpanda.
當我們在 Lightpanda 中實施更改時,我們會添加新的相關測試用例文件。
To add a new test, copy the file you want from the WPT repo into the tests/wpt directory.
要添加新測試,請將所需的文件從 WPT 存儲庫復制到該 tests/wpt 目錄中。
?? Please keep the original directory tree structure of tests/wpt.
?? 請保留 tests/wpt 的原始目錄樹結構。
五、軟件下載
夸克網盤分享
本文信息來源于GitHub作者地址:GitHub - lightpanda-io/browser: Lightpanda: the headless browser designed for AI and automation