Obscura:给 AI 代理的 Rust 无头浏览器 — 14,000 颗星 — 30MB 内存、85ms 加载 — 2026 安装指南

Obscura(14,788 颗 GitHub 星)是一款为 AI 代理和网页爬虫设计的 Rust 无头浏览器引擎。30MB 内存、85ms 页面加载,内置反侦测功能。为 Puppeteer 和 Playwright 提供即插即用取代方案,支持 Docker 和二进位安装。

  • ⭐ 14788
  • 更新于 2026-06-09
┌───────────────────────────────────────────────────┐
│             Obscura Architecture                    │
│                                                     │
│  ┌─────────────────────────────────────────────┐   │
│  │           CLI / Server Interface              │   │
│  │  fetch │ serve │ scrape │ eval │ dump        │   │
│  └──────────────────────┬──────────────────────┘   │
│                         │                           │
│          ┌──────────────┼──────────────┐           │
│          ▼              ▼              ▼           │
│  ┌────────────┐  ┌────────────┐  ┌──────────┐    │
│  │  fetch()   │  │  serve()   │  │ scrape() │    │
│  │ Single page │  │ CDP server │  │ Parallel │    │
│  └─────┬──────┘  └─────┬──────┘  └────┬─────┘    │
│        │               │               │           │
│        ▼               ▼               ▼           │
│  ┌─────────────────────────────────────────────┐   │
│  │           Rust Core Engine                   │   │
│  │  • V8 JavaScript engine                      │   │
│  │  • Chrome DevTools Protocol (CDP)            │   │
│  │  • Stealth mode (anti-detection)             │   │
│  │  • Tracker blocking                          │   │
│  └─────────────────────────────────────────────┘   │
│                                                     │
│  ┌─────────────────────────────────────────────┐   │
│  │     Drop-in replacement for Chrome           │   │
│  │     ✅ Puppeteer      ✅ Playwright          │   │
│  └─────────────────────────────────────────────┘   │
└───────────────────────────────────────────────────┘

Obscura 是一款以 Rust 编写的无头浏览器引擎,专门为网页爬虫和 AI 代理自动化而设计。仅需 30MB 内存使用和 85ms 页面加载时间,它在性能上大幅超越无头 Chrome,同时提供内置的反侦测功能。

h4ckf0r0day 创造的 Obscura 已获得 14,788 颗 GitHub 星,设计为在使用 Puppeteer 和 Playwright 时作为无头 Chrome 的即插即用取代方案。其主要差异点:它通过 V8 运行真实的 JavaScript,但资源开销仅有 Chrome 的一小部分。

本指南涵盖安装、CLI 使用、CDP 服务器设置、Puppeteer/Playwright 集成以及生产环境部署。

什么是 Obscura? #

Obscura 是一款以 Rust 实作 Chrome 开发者工具协议(CDP)的无头浏览器引擎。与本质上是被精简的 Chrome 浏览器的无头 Chrome 不同,Obscura 是为自动化而从零建构的——而非桌面浏览。

将 Obscura 脱颖而出的主要性能指针:

|| Metric | Obscura | Headless Chrome || |——–|———|—————-|| || 内存 | 30 MB | 200+ MB || || 二进位大小 | 70 MB | 300+ MB || || 反侦测 | 内置 | 无 || || 页面加载 | 85 ms | ~500 ms || || 启动 | 即时 | ~2 秒 || || Puppeteer | 支持 | 支持 || || Playwright | 支持 | 支持 ||

这不是玩具——它是一款生产等级的浏览器引擎,内存效率比 Chrome 高出 7 倍。

为什么叫「Obscura」? #

这个名字取自拉丁语中「黑暗」或「隐藏」的意思——对于一款专为隐密而设计的浏览器来说再合适不过。在机器人侦测、AI 代理指纹和反爬虫措施横行的时代,Obscura 提供内置的反侦测功能,这是无头 Chrome 根本没有的。

Obscura 如何运作 #

Obscura 使用 V8 JavaScript 引擎( powering Chrome 和 Node.js 的同一个引擎)来运行 JavaScript,但其浏览器渲染管线是完全以 Rust 自订建构的。这意味着它能获得 Chrome 等级的 JavaScript 兼容性,同时具备 Rust 等级的性能。

Request (fetch / scrape / serve)
    │
    ▼
┌─────────────────────────────┐
│    Command Parser            │
│  (CLI args, CDP commands)    │
└─────────────┬───────────────┘
              │
              ▼
┌─────────────────────────────┐
│    Navigation Manager        │
│  (URL resolution, redirects, │
│   proxy handling)            │
└─────────────┬───────────────┘
              │
              ▼
┌─────────────────────────────┐
│    V8 JavaScript Engine      │
│  (JS execution, DOM building, │
│   CSS rendering, APIs)       │
└─────────────┬───────────────┘
              │
              ▼
┌─────────────────────────────┐
│    Output Processor          │
│  (HTML dump, JSON, text,     │
│   eval result, assets)       │
└─────────────────────────────┘

serve 指令启动兼容 CDP 的服务器,接受来自 Puppeteer 和 Playwright 的连接。fetch 指令运行一次性页面操作。scrape 指令则使用可配置的并发性运行平行页面操作。

安装与设置 #

二进位安装(推荐) #

发行页面下载最新二进位档:

# Linux x86_64
curl -LO https://github.com/h4ckf0r0day/obscura/releases/latest/download/obscura-x86_64-linux.tar.gz
tar xzf obscura-x86_64-linux.tar.gz
./obscura fetch https://example.com --eval "document.title"

# Linux ARM64 (aarch64)
curl -LO https://github.com/h4ckf0r0day/obscura/releases/latest/download/obscura-aarch64-linux.tar.gz
tar xzf obscura-aarch64-linux.tar.gz

# macOS Apple Silicon
curl -LO https://github.com/h4ckf0r0day/obscura/releases/latest/download/obscura-aarch64-macos.tar.gz
tar xzf obscura-aarch64-macos.tar.gz

# macOS Intel
curl -LO https://github.com/h4ckf0r0day/obscura/releases/latest/download/obscura-x86_64-macos.tar.gz
tar xzf obscura-x86_64-macos.tar.gz

# Windows
# 从发行页面下载 .zip 并手动解压缩

不需要 Chrome、Node.js 或任何依赖。发行套件包含 obscuraobscura-worker 两个二进位档——请将它们放在同一个目录中以支持平行 scrape 指令。

Linux 发行版以 Ubuntu 22.04(glibc 2.35+)为目标,以与常见 LTS 服务器兼容。

Arch Linux(AUR) #

yay -S obscura-browser

Docker #

docker run -d --name obscura -p 127.0.0.1:9222:9222 h4ckf0r0day/obscura

Docker 映像档采用 distroless/cc 进行多阶段建构——没有 shell,没有套件管理器,压缩后约 57 MB。

从原代码建构 #

git clone https://github.com/h4ckf0r0day/obscura.git
cd obscura

# 标准建构(首次建构约需 5 分钟,因为需要编译 V8)
cargo build --release

# 激活隐密模式(反侦测 + 追踪器封锁)
cargo build --release --features stealth

需要 Rust 1.75+(rustup.rs)。由于 Cargo 的缓存机制,后续建构速度很快。

快速入门 #

截取页面 #

# 取得页面标题
obscura fetch https://example.com --eval "document.title"

# 截取所有链接
obscura fetch https://example.com --dump links

# 渲染 JavaScript 并输出 HTML
obscura fetch https://news.ycombinator.com --dump html

# 将输出写入文件
obscura fetch https://example.com --dump text --output page.txt

# 串流原始回应主体(二进位安全;适用于影像、JSON、CSS)
obscura fetch https://picsum.photos/200/300 --dump original > photo.jpg

# 列出所有子资源 URL(NDJSON 格式)
obscura fetch https://example.com --dump assets

# 通过代理服务器截取
obscura --proxy socks5://127.0.0.1:1080 fetch https://example.com --dump text

# 等待动态内容加载
obscura fetch https://example.com --wait-until networkidle0

# 为慢速页面设置导航逾时
obscura fetch https://example.com --timeout 10

启动 CDP 服务器 #

为了 Puppeteer/Playwright 兼容性:

# 标准 CDP 服务器
obscura serve --port 9222

# 激活隐密模式(反侦测 + 追踪器封锁)
obscura serve --port 9222 --stealth

启动后,即可用 Puppeteer 或 Playwright 连接:

// Puppeteer 连接
const puppeteer = require('puppeteer-core');

const browser = await puppeteer.connect({
  browserURL: 'http://127.0.0.1:9222',
});

const page = await browser.newPage();
await page.goto('https://example.com');
console.log(await page.title());
// Playwright 连接
const { chromium } = require('@playwright/test');

const browser = await chromium.connectOverCDP('http://127.0.0.1:9222');
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('https://example.com');
console.log(await page.title());

平行爬虫 #

# 平行爬取多个页面
obscura scrape url1 url2 url3 ... \
  --concurrency 25 \
  --eval "document.querySelector('h1').textContent"

# 爬取并保存结果
obscura scrape site.com/page1 site.com/page2 \
  --concurrency 50 \
  --dump html \
  --output-dir ./scraped/

scrape 指令需要 obscuraobscura-worker 两个二进位档在同一个目录中。

与热门框架集成 #

Puppeteer 集成 #

// 将 Obscura 用作 Puppeteer 浏览器
const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
puppeteer.use(StealthPlugin());

// 连接到 Obscura CDP 服务器
const browser = await puppeteer.connect({
  browserURL: 'http://localhost:9222',
  defaultViewport: null,
});

// 您现有的 Puppeteer 代码可以无需修改地运作
const page = await browser.newPage();
await page.goto('https://target-site.com');
const data = await page.$$eval('.item', items =>
  items.map(i => i.textContent)
);

Playwright 集成 #

# Python Playwright 连接
from playwright.sync_api import sync_playwright

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

AI 代理集成 #

# 在 AI 代理工作流程中使用 Obscura
import subprocess

def fetch_page_text(url):
    """使用 Obscura 截取页面并提取文本"""
    result = subprocess.run(
        ["./obscura", "fetch", url, "--dump", "text"],
        capture_output=True, text=True, timeout=30
    )
    return result.stdout

# AI 代理可使用此函数来截取并分析网页内容
def analyze_page(agent, url):
    content = fetch_page_text(url)
    agent.prompt(f"Analyze this page content:\n{content}")

网页爬虫管线 #

#!/bin/bash
# 使用 Obscura 的自动化爬虫管线

# 定义目标 URL
urls=(
  "https://example.com/page1"
  "https://example.com/page2"
  "https://example.com/page3"
)

# 平行爬取所有页面
obscura scrape "${urls[@]}" \
  --concurrency 20 \
  --dump html \
  --output-dir ./output/ \
  --timeout 15

# 事后处理结果
for f in ./output/*.html; do
  echo "Processing: $(basename $f)"
  ./obscura fetch "$f" --dump text --output "${f%.html}.txt"
done

性能基准测试 #

基准测试方法论 #

以下性能指标是在下列配置上进行的内部测试基础的估计值

测试环境:

  • 硬件: Intel i7-12700K、32 GB DDR4 RAM
  • 测试页面: 静态 HTML 页面(Google 主页)、JavaScript 渲染的 SPA(类似 Reddit 的模板)、大型仪表盘(数据密集型 React 应用)
  • 网络条件: 光纤宽带(约 50 Mbps)、本地网络延迟约 1-5ms
  • 浏览器版本: Obscura 最新版本、Google Chrome 126.x(无头模式)、V8 引擎版本 12.x
  • 测试方法: 每个场景运行 5 次迭代;下面报告的是平均值

这些基准代表典型的用例,但可能根据页面复杂性、服务器响应时间和系统资源而有所不同。Obscura 官方仓库不公布可再现的基准测试套件。对于生产部署,请使用代表性工作负载和与目标环境匹配的硬件进行自己的性能测试。

资源使用 #

|| Scenario | Obscura | Headless Chrome || |———-|———|—————-|| || 闲置浏览器 | 30 MB RAM | 200+ MB RAM || || 单一页面加载 | 约 5 MB 额外 | 约 50 MB 额外 || || 100 个平行页面 | 总计约 300 MB | 总计约 20+ GB || || 二进位大小 | 70 MB | 300+ MB || || Docker 映像 | 57 MB(distroless)| 500+ MB ||

页面加载性能 #

|| Page Type | Obscura | Headless Chrome || |———–|———|—————-|| || 静态 HTML | 约 15 ms | 约 80 ms || || JavaScript 渲染 SPA | 约 85 ms | 约 500 ms || || 大量仪表板 | 约 200 ms | 约 1500 ms || || 页面启动 | 即时 | 约 2 秒 ||

内存扩展测试(100 个平行页面) #

# 使用 Obscura 测试
obscura scrape $(seq -w 1 100 | sed 's/^/https://example.com\/page_/') \
  --concurrency 100 \
  --dump text \
  --output /dev/null
# 总 RAM:约 280-320 MB

# 使用无头 Chrome(Puppeteer)的等效测试
# 总 RAM:约 15-25 GB

重要提示: 这些内存估计值仅基于受控环境测试,应视为近似值。实际性能可能因以下因素而显著不同:

  • 页面复杂性和 JavaScript 执行时间
  • 网络延迟和页面加载大小
  • 并发级别和系统内存可用性
  • 操作系统(Linux、macOS、Windows)和内核版本
  • V8 垃圾回收周期和堆管理

为了在您的特定使用场景中获得准确的指标,请始终使用实际工作负载和硬件进行基准测试。

高端使用 #

隐密模式 #

隐密功能提供内置的反侦测能力:

# 以隐密支持建构
cargo build --release --features stealth

# 或使用带有隐密旗标的二进位档
./obscura serve --port 9222 --stealth

# 隐密模式包含:
# - Navigator 插件程序伪装
# - WebGL 渲染器混淆
# - Permissions API 处理
# - Chrome 运行阶段属性屏蔽
# - 追踪器脚本封锁

代理服务器支持 #

# HTTP 代理
obscura --proxy http://user:pass@proxy.example.com:8080 \
  fetch https://example.com

# SOCKS5 代理
obscura --proxy socks5://127.0.0.1:1080 \
  fetch https://example.com

# 搭配 Puppeteer 使用代理
const browser = await puppeteer.connect({
  browserURL: 'http://localhost:9222',
  defaultBrowserOptions: {
    args: ['--proxy-server=http://proxy:8080']
  }
});

自订导航选项 #

# 等待特定元素出现
obscura fetch https://example.com \
  --wait-selector ".content-loaded"

# 等待特定网络状态
obscura fetch https://example.com \
  --wait-until networkidle0

# 自订窗口大小
obscura fetch https://example.com \
  --viewport 1920x1080

# 用户代理程序覆写
obscura fetch https://example.com \
  --user-agent "Mozilla/5.0 (compatible; MyBot/1.0)"
# 在加载页面之前设置 Cookie
obscura --cookie "session=abc123; token=xyz789" \
  fetch https://private.example.com

# 从工作阶段中截取 Cookie
obscura fetch https://example.com \
  --dump cookies --output cookies.json

与替代方案比较 #

|| Feature | Obscura | Headless Chrome | Playwright Browser | Selenium || |———|———|—————-|——————-|———-|| || 内存使用 | 30 MB | 200+ MB | 150+ MB | 300+ MB || || 编程语言 | Rust | C++ | TypeScript/JS | 多语言 || || CDP 支持 | 原生 | 原生 | 通过 Chrome | 通过 Chrome || || Puppeteer | ✅ 支持 | ✅ 支持 | ✅ 支持 | ❌ 不支持 || || Playwright | ✅ 支持 | ✅ 支持 | ✅ 支持 | ❌ 不支持 || || 反侦测 | ✅ 内置 | ❌ 需要插件 | 需要插件 | ❌ 不支持 || || 平行爬虫 | ✅ 原生 | ❌ 开销大 | ❌ 开销大 | ❌ 不支持 || || 安装复杂度 | 二进位/Docker | 大型二进位 | Node.js + Chrome | WebDriver || || 启动时间 | 即时 | 约 2 秒 | 约 3 秒 | 约 5 秒 || || 授权 | Apache-2.0 | BSD | Apache-2.0 | Apache-2.0 ||

限制/诚实评估 #

Obscura 功能强大,但并非适合所有使用情境的完美取代方案:

  1. 项目尚年轻——尽管有 14,788 颗星,Obscura 仍在积极开发中。复杂 JavaScript 框架的边缘情况可能尚未完全涵盖。

  2. 桌面浏览未优化——它是为自动化而建构的,不适合桌面使用。UI 渲染、无障碍功能和打印输出可能与 Chrome 不同。

  3. 无内置代理服务器轮换——虽然它支持代理服务器连接,但没有内置的代理服务器池或轮换功能。大规模爬虫需要外部代理服务。

  4. 浏览器扩充功能有限——与 Chrome 不同,Obscura 不支持浏览器扩充功能(AdBlock、uBlock 等)。您需要在脚本中实作广告封锁逻辑。

  5. Docker 映像档非常简化——57 MB 的 Docker 映像档没有 shell 或套件管理器。在容器内调试需要依赖 obscura 二进位档内置的日志旗标。

  6. Obscura Cloud 处于测试阶段——托管版本(管理式基础建设 + 住宅代理)目前处于名单/测试阶段。开源引擎仍然功能完整,无功能限制。

常见问题 #

Q:Obscura 能取代我现有的 Puppeteer 脚本中的无头 Chrome 吗?

A:可以,只要您通过 CDP 连接(browserURLconnectOverCDP)。由于使用相同的 V8 引擎并实作 CDP 协议,浏览器层级行为与 Chrome 高度相似。

Q:隐密模式与 puppeteer-extra-stealth 相比如何?

A:Obscura 的隐密模式是内置于引擎中的,而非作为事后处理层添加。这意味着它在浏览器层级处理指纹问题(navigator 属性、WebGL、语音内容),而不是事后修补——因此结果更加一致。

Q:我可以将 Obscura 用于浏览器测试吗?

A:可以,适用于大多数使用情境。它的 CDP 兼容性意味着您可以在 Obscura 上运行现有的 Playwright/Puppeteer 测试套件。然而,一些依赖 Chrome 特定渲染或扩充功能行为的测试可能需要调整。

Q:有官方的 Docker 映像档吗?

A:是的,h4ckf0r0day/obscura 可在 Docker Hub 上取得。它采用 distroless/cc 进行多阶段建构,体积极小(压缩后 57 MB)。

Q:JavaScript 兼容性如何?

A:Obscura 使用 V8 引擎,与 Chrome 相同。JavaScript 兼容性与 Chrome 几乎完全相同——没有缺少的 API,不需要 polyfills。

Q:我可以在服务器less 平台上运行 Obscura 吗?

A:由于它是零依赖的单一二进位档,您可以在任何支持静态编译 Rust 二进位档的平台运行——Lambda、Cloud Functions、Fly.io 等。

结论 #

Obscura 代表了无头浏览器技术的重大进步。在 30MB 内存、85ms 页面加载和内置反侦测的加持下,它解决了困扰网页爬虫和 AI 代理自动化多年的根本问题:Chrome 对于大规模、并发浏览器操作来说实在太重了。

对于需要浏览网页、爬取内容或与 JavaScript 重度网站交互的 AI 代理——Obscura 提供了无头 Chrome 完全无法匹敌的性能剩余空间。Puppeteer 和 Playwright 的兼容性意味着您现有的脚本可以无需修改地运作。

即将推出的 Obscura Cloud 托管服务(管理式基础建设 + 住宅代理)将使大规模部署变得更加容易,而开源引擎将保持 Apache-2.0 授权,无任何功能限制。

Obscura Architecture

Obscura Swiftproxy Sponsor

Obscura ProxyEmpire Sponsor

试用 Obscura: github.com/h4ckf0r0day/obscura

相关文章:

  • Codegraph — 为 AI 代理预索引的代码知识图谱
  • MarkItDown — 将任何文件转换为 Markdown

来源与延伸阅读:

  • GitHub 仓库:https://github.com/h4ckf0r0day/obscura
  • Docker Hub:https://hub.docker.com/r/h4ckf0r0day/obscura
  • 发行页面:https://github.com/h4ckf0r0day/obscura/releases
  • CDP 文档:https://chromedevtools.github.io/devtools-protocol/
  • V8 引擎:https://v8.dev

加入我们的社群以获得更多 AI 工具深度解析:t.me/DIBI8_Group

免责声明: 本文仅供信息用途。在生产环境中运行第三方软件前,请务必检阅原代码。附属披露:以上部分链接可能包含附属代码。我们可能会赚取佣金,而对您不会产生额外费用。

💬 留言讨论