当前位置: 首页 > news >正文

Lightpanda开源浏览器:专为 AI 和自动化而设计的无界面浏览器

​一、软件介绍

文末提供程序和源码下载

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

相关文章:

  • 安卓基础(Bitmap)
  • scons user 3.1.2
  • C#强类型枚举的入门理解
  • C++【STL】(2)string
  • 4级流程控制
  • 复现:DemoGen 用于数据高效视觉运动策略学习的 合成演示生成 (RSS) 2025
  • Docker 常见问题及其解决方案
  • nginx报错-[emerg] getpwnam(“nginx“) failed in /etc/nginx/nginx.conf:2
  • FastAPI + OpenAI 模型 的 GitHub 项目结构模板
  • 未来软件开发趋势与挑战
  • Python+Selenium爬虫:豆瓣登录反反爬策略解析
  • C#调用C++dll 过程记录
  • 【VS】VS2019中使用rdlc报表,生成之前修改XML
  • 【每天一个知识点】模型轻量化(Model Compression and Acceleration)技术
  • 解释 RESTful API
  • 数据结构学习之链表学习:单链表
  • Linux笔记---信号(中)
  • AIGC与数字媒体实验室解决方案分享
  • LabVIEW在电子电工教学中的应用
  • 腾讯云运营开发 golang一面
  • 著名植物学家、园艺学家,国际植物园协会原主席贺善安逝世
  • 周启鸣加盟同济大学,曾任香港浸会大学深圳研究院院长
  • 小米SU7 Ultra风波升级:数百名车主要求退车,车主喊话雷军“保持真诚”
  • 媒体和打拐志愿者暗访长沙一地下代孕实验室,警方已控制涉案人员
  • 德国将不再公布对乌克兰军事支持的细节
  • 《中国人民银行业务领域数据安全管理办法》发布,6月30日起施行