用途
fast-browser-use 是一个基于 Rust 的浏览器自动化引擎,以轻量二进制形式通过 CDP 直接驱动 Chrome。它面向需要高速、低资源占用且对 AI 友好的网页自动化任务,尤其适合需要维持状态(如保持登录)、处理动态 JavaScript 内容或同时管理多个页面的复杂交互场景。
主要能力
视觉与提取
- vision_map:返回带编号边界框的截图叠加层,标注所有可交互元素。
- snapshot:捕获原始 HTML 快照(针对 AI 优化的 YAML/Markdown 格式)。
- screenshot:捕获页面视觉图像。
- extract:从 DOM 获取结构化数据。
- markdown:将当前页面内容转换为 Markdown。
- sitemap:通过 robots.txt、站点地图和页面语义分析站点结构。
导航与生命周期
- navigate:访问指定 URL。
- go_back / go_forward:在浏览器历史中前进或后退。
- wait:暂停执行或等待特定条件。
- new_tab / switch_tab / close_tab / tab_list:新建、切换、关闭和列出标签页。
- close:终止浏览器会话。
交互
- click:通过 CSS 选择器或 DOM 索引点击元素。
- input:向字段输入文本。
- press_key:发送特定键盘事件。
- hover:悬停在元素上。
- scroll:滚动视口。
- select:在下拉框中选择选项。
状态与调试
- cookies:管理会话 Cookie(获取/设置)。
- local_storage:管理本地存储数据。
- debug:访问控制台日志和调试信息。
使用方式
以下命令示例均来自官方资料,保留原始内容。
1. 通过人类模拟绕过机器人检测
模拟鼠标抖动和随机延迟以抓取受保护站点:
fast-browser-use navigate --url "https://protected-site.com" \
--human-emulation \
--wait-for-selector "#content"
2. 深度冻结快照
捕获整个 DOM 状态和计算样式,以便后续完美重建:
fast-browser-use snapshot --include-styles --output state.json
3. 登录与 Cookie 复用
手动登录一次,然后窃取会话用于无头自动化。
步骤 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
4. 无限滚动采集器
从无限滚动页面提取最新数据,适合采集最新帖子、新闻或社交动态。
# Harvest headlines from Hacker News (scrolls 3x, waits 800ms between)
fast-browser-use harvest \
--url "https://news.ycombinator.com" \
--selector ".titleline a" \
--scrolls 3 \
--delay 800 \
--output headlines.json
实际输出(约 6 秒内获得 59 个唯一项):
[
"Genode OS is a tool kit for building highly secure special-purpose OS",
"Mobile carriers can get your GPS location",
"Students using \"humanizer\" programs to beat accusations of cheating with AI",
"Finland to end \"uncontrolled human experiment\" with ban on youth social media",
...
]
适用于任何无限滚动页面:Reddit、Twitter、LinkedIn 信息流、搜索结果等。
5. 快速截图
将任意页面捕获为 PNG:
fast-browser-use screenshot \
--url "https://example.com" \
--output page.png \
--full-page # Optional: capture entire scrollable page
6. 站点地图与页面结构分析器
通过解析站点地图和分析页面结构来了解站点组织方式。
# Basic sitemap discovery (checks robots.txt + common sitemap URLs)
fast-browser-use sitemap --url "https://example.com"
# Full analysis with page structure (headings, nav, sections)
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 - Home",
"headings": [
{"level": 1, "text": "Welcome to Example"},
{"level": 2, "text": "Our Services"}
],
"nav_links": [
{"text": "About", "href": "/about"},
{"text": "Products", "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 company homepage",
"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 动态渲染的页面。
- 同时管理多个标签页或并发会话。
- 从无限滚动页面(如 Reddit、Twitter、LinkedIn 信息流、搜索结果)采集数据。
- 在抓取前分析站点结构、导航流程或审计 SEO 结构。
- 对启动速度和内存占用敏感的自动化任务。
限制
资料中未提供关于收费、价格、支持平台、安装方式或具体效果保证的说明,这些信息暂未提供。