小马的 AI 工具集 给 Agent 学习

无头浏览器

Rust 写的轻量无头浏览器引擎,为 AI 智能体和爬虫提供反检测自动化

无头浏览器
类型 CLI 15,732 星标 更新 2026-06-13 许可 Apache-2.0 原仓库

Obscura

Obscura

面向 AI 代理与网络爬虫的开源无头浏览器
轻量、隐蔽、用 Rust 构建


Obscura 是一个用 Rust 编写的无头浏览器引擎,专为网络爬虫和 AI 代理自动化而设计。它通过 V8 运行真实 JavaScript,支持 Chrome DevTools 协议,可作为 Puppeteer 和 Playwright 环境下无头 Chrome 的直接替代品。

为什么选择 Obscura 而非无头 Chrome?

专为规模化自动化而生,而非桌面浏览。

MetricObscuraHeadless Chrome
Memory30 MB200+ MB
Binary size70 MB300+ MB
Anti-detectBuilt-inNone
Page load85 ms~500 ms
StartupInstant~2s
PuppeteerYesYes
PlaywrightYesYes

🎉 10,000 颗星及未来计划

我们正在开发 Obscura Cloud 托管版本,提供托管基础设施、住宅代理和专属支持。适合希望直接使用引擎而无需自行运维的用户。

开源引擎将保持 Apache-2.0 许可,功能完整。永远不会限制功能。

加入等候名单 →

赞助商

Obscura 的持续独立开发离不开赞助商的支持。

有意赞助?请发送邮件至 hello@obscura.sh

Swiftproxy Swiftproxy — 专为隐私、自动化和规模化打造的高品质住宅代理。

覆盖 190+ 国家的 8000 万+ 住宅 IP
轮换与粘性会话
流量永不过期
提供免费试用
可按国家、州和城市定位
支持 HTTP、HTTPS 和 SOCKS5

🎁 使用优惠码 PROXY90 享受 9 折优惠。

ProxyEmpire 🚀 Obscura × ProxyEmpire
使用 Obscura 进行 AI 代理、浏览器自动化或网络爬虫?用来自 ProxyEmpire 的可靠住宅和移动代理为其赋能。

🌍 覆盖 170+ 国家的 3000 万+ 住宅 IP
📱 4G/5G 移动代理
🔄 轮换与粘性会话
🎯 城市、区域和 ISP 定位
🔐 支持 HTTP、HTTPS 和 SOCKS5

🎁 使用优惠码 OBSCURA35 享受 35% 长期折扣

更优质的代理。更少的拦截。更可扩展的自动化。
MangoProxy MangoProxy 提供覆盖 200+ 国家的住宅、ISP、数据中心和移动代理。凭借稳定的连接、快速的响应时间和可扩展的代理基础设施,深受全球企业信赖。
使用促销代码 OBSCURA 可享静态 ISP 代理 8 折优惠。

安装

下载

Releases 获取最新二进制文件:

# 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

# Arch Linux (AUR)
yay -S obscura-browser

# 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
Download the `.zip` from the releases page and extract it manually.

无需 Chrome、无需 Node.js、无任何依赖。发布归档同时包含 obscuraobscura-worker;请将它们放在同一目录下,以便并行 scrape 命令使用。

Linux 发布版以 Ubuntu 22.04 为目标构建,因此下载的二进制文件可在使用 glibc 2.35+ 的常见 LTS 服务器上直接运行。

Docker

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

镜像位于 Docker Hub。基于 distroless/cc 的多阶段构建,不含 shell 和包管理器,压缩后约 57 MB。

从源码构建

git clone https://github.com/h4ckf0r0day/obscura.git
cd obscura
cargo build --release

# 启用隐身模式(反检测 + 跟踪拦截)
cargo build --release --features stealth

需要 Rust 1.75+(rustup.rs)。首次构建约需 5 分钟(V8 从源码编译,之后会缓存)。

快速开始

获取页面

# 获取页面标题
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

# 将导出或 eval 结果写入文件
obscura fetch https://example.com --dump text --output page.txt

# 直接流式输出原始响应体(二进制安全;绕过 JS/DOM 层)。
# 适用于图片、JSON、JS、CSS 或任何非 HTML 资源。
obscura fetch https://picsum.photos/200/300 --dump original > photo.jpg

# 列出页面会获取的每个子资源 URL(NDJSON 格式;每个资源一条记录)
obscura fetch https://example.com --dump assets

# 通过 HTTP 或 SOCKS 代理获取
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 服务器

obscura serve --port 9222

# 启用隐身模式(反检测 + 跟踪器拦截)
obscura serve --port 9222 --stealth

并行抓取

obscura scrape url1 url2 url3 ... \
  --concurrency 25 \
  --eval "document.querySelector('h1').textContent" \
  --format json

# 在 stderr 上抑制抓取进度,输出更适合脚本使用
obscura scrape https://example.com --quiet --format json

# 抓取进程继承全局代理
obscura --proxy http://127.0.0.1:8080 scrape https://example.com https://news.ycombinator.com

Puppeteer / Playwright

Puppeteer

npm install puppeteer-core
import puppeteer from 'puppeteer-core';

const browser = await puppeteer.connect({
  browserWSEndpoint: 'ws://127.0.0.1:9222/devtools/browser',
});

const page = await browser.newPage();
await page.goto('https://news.ycombinator.com');

const stories = await page.evaluate(() =>
  Array.from(document.querySelectorAll('.titleline > a'))
    .map(a => ({ title: a.textContent, url: a.href }))
);
console.log(stories);

await browser.disconnect();

Playwright

npm install playwright-core
import { chromium } from 'playwright-core';

const browser = await chromium.connectOverCDP({
  endpointURL: 'ws://127.0.0.1:9222',
});

const page = await browser.newContext().then(ctx => ctx.newPage());
await page.goto('https://en.wikipedia.org/wiki/Web_scraping');
console.log(await page.title());

await browser.close();

表单提交与登录

await page.goto('https://quotes.toscrape.com/login');
await page.evaluate(() => {
  document.querySelector('#username').value = 'admin';
  document.querySelector('#password').value = 'admin';
  document.querySelector('form').submit();
});
// Obscura 处理 POST 请求,跟踪 302 重定向,保持 Cookie

基准测试

页面加载:

页面ObscuraChrome
静态 HTML51 ms~500 ms
JS + XHR + fetch84 ms~800 ms
动态脚本78 ms~700 ms

完整的基准测试套件(WPT 一致性、障碍课程、真实语料库以及 vs-Chrome 速度)位于单独的仓库中:https://github.com/h4ckf0r0day/obscura-benchmark

隐身模式

使用 --features stealth 启用。

反指纹识别

  • 每会话指纹随机化(GPU、屏幕、Canvas、音频、电池)
  • 真实的 navigator.userAgentData(Chrome 145,高熵值)
  • 分发事件时 event.isTrusted = true
  • 隐藏内部属性(Object.keys(window) 安全)
  • 原生函数伪装(Function.prototype.toString()[native code]
  • navigator.webdriver = undefined(与真实 Chrome 一致)

跟踪器拦截

  • 拦截 3,520 个域名
  • 阻止分析、广告、遥测和指纹识别脚本
  • 完全阻止跟踪器加载
  • 使用 --stealth 自动启用

CDP API

Obscura 实现了 Chrome DevTools 协议,以兼容 Puppeteer/Playwright。

方法
TargetcreateTarget, closeTarget, attachToTarget, createBrowserContext, disposeBrowserContext
Pagenavigate, getFrameTree, addScriptToEvaluateOnNewDocument, lifecycleEvents
Runtimeevaluate, callFunctionOn, getProperties, addBinding
DOMgetDocument, querySelector, querySelectorAll, getOuterHTML, resolveNode
Networkenable, setCookies, getCookies, setExtraHTTPHeaders, setUserAgentOverride
Fetchenable, continueRequest, fulfillRequest, failRequest(实时拦截)
StoragegetCookies, setCookies, deleteCookies
InputdispatchMouseEvent, dispatchKeyEvent
LPgetMarkdown(DOM 到 Markdown 的转换)

CLI 参考

调优 V8

Obscura 直接嵌入 V8。使用 --v8-flags 将原始标志传递给 V8,语法与 Chromium 的 --js-flags 和 Node 的命令行标志相同。最常见的用途是在 JS 密集型页面上提高堆上限以修复 JavaScript heap out of memory 错误:

obscura --v8-flags "--max-old-space-size=4096" fetch <url>

obscura serve

启动一个 CDP WebSocket 服务器。

标志默认值描述
--port9222WebSocket 端口
--proxyHTTP/SOCKS5 代理 URL
--stealth关闭启用反检测 + 跟踪器拦截
--workers1并行工作进程数量
--obey-robots关闭遵守 robots.txt

obscura fetch <URL>

获取并渲染单个页面。

标志默认值描述
--dumphtml输出格式:htmltextlinksmarkdownassets(页面上所有子资源 URL 的 NDJSON)或 original(原始响应体)
--eval要评估的 JavaScript 表达式
--wait-untilload等待条件:loaddomcontentloadednetworkidle0
--timeout30最大导航时间(秒)
--selector等待 CSS 选择器
--stealth关闭反检测模式
--output将 dump 或 eval 输出写入文件
--quiet关闭抑制横幅输出
--proxy继承的全局 HTTP/SOCKS5 代理 URL

obscura scrape <URL...>

使用工作进程并行抓取多个 URL。

标志默认值描述
--concurrency10并行工作进程数
--eval每个页面的 JS 表达式
--formatjson输出格式:jsontext
--quiet关闭在 stderr 上抑制抓取进度
--proxy所有工作进程继承的全局 HTTP/SOCKS5 代理 URL

MCP(模型上下文协议)

Obscura 内置一个 MCP 服务器,向 AI 代理(Claude Desktop、Cursor 等)暴露浏览器自动化工具。

启动

stdio(默认)——适用于 Claude Desktop 和启动子进程的 MCP 客户端:

obscura mcp

HTTP——适用于通过网络连接的客户端:

obscura mcp --http --port 8080
# 端点:http://127.0.0.1:8080/mcp

可选标志(两种传输方式共用):

标志描述
--proxy <URL>HTTP/SOCKS5 代理
--user-agent <UA>自定义 User-Agent 字符串
--stealth启用反检测模式

Claude Desktop 配置

{
  "mcpServers": {
    "obscura": {
      "command": "obscura",
      "args": ["mcp"]
    }
  }
}

工具

工具描述
browser_navigate导航到指定 URL(url,可选参数 waitUntilload / domcontentloaded / networkidle0
browser_snapshot返回当前页面的 URL、标题和正文文本
browser_click通过 CSS 选择器点击元素
browser_fill设置输入框的值(触发 input + change 事件)
browser_type向输入框追加文本
browser_press_key分发键盘事件(key,可选参数 selector
browser_select_option按值或文本选择 <option> 元素
browser_evaluate评估 JavaScript 表达式并返回结果
browser_wait_for等待 CSS 选择器出现(selector,可选参数 timeout(秒))
browser_network_requests列出当前页面发出的网络请求
browser_console_messages返回页面记录的 console 消息
browser_close关闭页面并释放上下文

许可证

Apache 2.0


在 GitHub 查看完整项目