名称: fast-browser-use
displayName: 极速浏览器自动化
emoji: "⚡"
摘要: 基于 Rust 的浏览器自动化工具,DOM 解析速度比 Puppeteer 快 10 倍。
主页: https://github.com/rknoche6/fast-browser-use
primaryEnv: bash
os:
- darwin
- linux
requires:
bins:
- chrome
install:
- kind: brew
formula: rknoche6/tap/fast-browser-use
- kind: cargo
package: fast-browser-use
config:
requiredEnv:
- CHROME_PATH
example: |
# 标准无头模式设置
export CHROME_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
export BROWSER_HEADLESS="true"
一个基于 Rust 的浏览器自动化引擎,通过一个轻量级二进制文件直接驱动 Chrome(通过 CDP 协议)。它针对高效令牌提取、稳健的会话管理和速度进行了优化。
模拟鼠标抖动和随机延迟来抓取受保护的网站。
fast-browser-use navigate --url "https://protected-site.com" \
--human-emulation \
--wait-for-selector "#content"
捕获完整的 DOM 状态以及计算样式,以便后续完美重建。
fast-browser-use snapshot --include-styles --output state.json
手动登录一次,然后窃取会话用于无头自动化。
步骤 1:打开非无头浏览器进行手动登录
fast-browser-use login --url "https://github.com/login" --save-session ./auth.json
步骤 2:后续复用会话
fast-browser-use navigate --url "https://github.com/dashboard" --load-session ./auth.json
从无限滚动页面提取最新数据——非常适合获取最新的帖子、新闻或社交媒体动态。
# 从 Hacker News 收割标题(滚动 3 次,每次间隔 800 毫秒)
fast-browser-use harvest \
--url "https://news.ycombinator.com" \
--selector ".titleline a" \
--scrolls 3 \
--delay 800 \
--output headlines.json
真实输出(约 6 秒内获取 59 个唯一项目):
[
"Genode OS 是一个用于构建高度安全的专用操作系统的工具包",
"移动运营商可以获取您的 GPS 位置",
"学生使用“人性化”程序来应对 AI 作弊指控",
"芬兰将结束“不受控制的人类实验”,禁止青少年使用社交媒体",
...
]
适用于任何无限滚动页面:Reddit、Twitter、LinkedIn 动态、搜索结果等。
将任何页面捕获为 PNG:
fast-browser-use screenshot \
--url "https://example.com" \
--output page.png \
--full-page # 可选:捕获整个可滚动页面
通过解析站点地图和分析页面结构来了解网站的组织方式。
# 基础站点地图发现(检查 robots.txt + 常见站点地图 URL)
fast-browser-use sitemap --url "https://example.com"
# 包含页面结构的完整分析(标题、导航、区块)
fast-browser-use sitemap \
--url "https://example.com" \
--analyze-structure \
--max-pages 10 \
--max-sitemaps 5 \
--output site-structure.json
选项:
- --analyze-structure: 同时提取页面结构(标题、导航、区块、元数据)
- --max-pages N: 将结构分析限制在 N 个页面内(默认:5)
- --max-sitemaps N: 将站点地图解析限制在 N 个站点地图内(默认:10,适用于大型网站)
示例输出:
{
"base_url": "https://example.com",
"robots_txt": "User-agent: *\nSitemap: https://example.com/sitemap.xml",
"sitemaps": ["https://example.com/sitemap.xml"],
"pages": [
"https://example.com/about",
"https://example.com/products",
"https://example.com/contact"
],
"page_structures": [
{
"url": "https://example.com",
"title": "Example - 主页",
"headings": [
{"level": 1, "text": "欢迎来到 Example"},
{"level": 2, "text": "我们的服务"}
],
"nav_links": [
{"text": "关于", "href": "/about"},
{"text": "产品", "href": "/products"}
],
"sections": [
{"tag": "main", "id": "content", "role": "main"},
{"tag": "footer", "id": "footer", "role": null}
],
"main_content": {"tag": "main", "id": "content", "word_count": 450},
"meta": {
"description": "Example 公司主页",
"canonical": "https://example.com/"
}
}
]
}
可在抓取前用于了解网站架构、映射导航流程或审计 SEO 结构。
| 特性 | Fast Browser Use (Rust) | Puppeteer (Node) | Selenium (Java) |
|---|---|---|---|
| 启动时间 | < 50ms | ~800ms | ~2500ms |
| 内存占用 | 15 MB | 100 MB+ | 200 MB+ |
| DOM 提取 | 零拷贝 | JSON 序列化 | 慢速桥接 |
此技能专为需要维护状态(如保持登录)、处理动态 JavaScript 内容或同时管理多个页面的复杂网页交互而设计。与标准的基于 fetch 的工具相比,它提供了更高的性能和控制力。