进阶 rtrvr.ai 2026-11-23 19:18:26 · 1 阅读

第5章 浏览器自动化 CLI 工具 rtrvr

第5章 Browser automation CLI

RUN 随时随地运行

在终端、CI 或其他 agent 中启动浏览器任务。可选择 Cloud、本机 Chrome 浏览器,或让 rtrvr 自动路由。

从 npm 安装 / 在 GitHub 上打开

01 Cloud

在托管的云端浏览器中运行,摆脱对本机电脑的依赖。

02 Chrome

直接使用本机已登录的 Chrome 浏览器。

03 Auto

Chrome 可用就用 Chrome,不可用则自动切到 Cloud。

CLI(全局安装)

npm install -g @rtrvr-ai/cli

编程接口(API)

curl https://api.rtrvr.ai/agent

CLI 提供 rtrvr 命令;需要编程调用的场景可以直接使用 HTTP API。

1 认证登录

rtrvr auth login

2 运行第一个任务

CLI

rtrvr run "Extract the top 10 products and prices" --url https://example.com

3 更多探索

# 抓取页面 rtrvr scrape --url https://example.com

# 查看当前能力 rtrvr capabilities

# 运行诊断 rtrvr doctor

指定浏览器在哪里运行。用 --target 指定,或保持 Auto 模式让同一任务在不同环境下都能工作。

01 --cloud(Cloud)

在托管浏览器中运行,不占用本机设备。适合公开页面、定时任务和无人值守场景。

02 --extension(Chrome)

使用本机已登录的 Chrome 浏览器。适合私有应用、SSO 登录和内部工具。

03 --target auto(Auto,默认)

Chrome 可用就用 Chrome,不可用则回退到 Cloud。适合需要跨环境可移植的任务。

Auto 路由

rtrvr run "task"

Chrome 在线 → 在 Chrome 中运行;无设备 → 在 Cloud 中运行。

响应中会包含路由元数据,说明实际选用的模式以及是否发生了回退:

{ "metadata": { "selectedMode": "cloud", "fallbackApplied": true, "fallbackReason": "no extension devices online" } }

# 位置参数传入 rtrvr run "Find the latest pricing for each plan" --url https://example.com

# 从文件读取 rtrvr run --input-file ./task.txt --url https://example.com --target cloud

# 从标准输入读取 echo "Summarize this page" | rtrvr run --url https://example.com

:任务描述(位置参数) --input :任务描述(flag 形式的替代写法) --input-file :从文件读取任务描述 --url :agent 的目标 URL --target :路由模式,可选 auto、cloud 或 extension(默认 auto) --cloud:--target cloud 的简写 --extension:--target extension 的简写 --device-id :指定某个浏览器扩展设备 --schema-file :结构化输出的 JSON schema 文件 --json:输出机器可读的 JSON --no-stream:关闭实时进度流

编程方式的云端运行可以直接调用已认证的 HTTP API。

创建一次运行

curl -X POST https://api.rtrvr.ai/agent \ -H "Authorization: Bearer $RTRVR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "input": "Find latest headline and author", "urls": ["https://example.com"], "target": "auto" }'

客户端选项

apiKey:你的 rtrvr API 密钥(rtrvr_...) defaultTarget:默认路由模式(默认 auto) baseUrl:覆盖 API 地址(默认 https://api.rtrvr.ai) mcpUrl:覆盖 MCP 地址(默认 https://mcp.rtrvr.ai)

统一的 Run 调用

{ "input": "Find latest headline and author", "urls": ["https://example.com"], "target": "auto" }

直接调用工具

CLI

rtrvr raw extract_from_tab --user_input "Extract all product names and prices" --tab_urls '["https://example.com/products"]' rtrvr raw act_on_tab --user_input "Click the Sign Up button" --tab_urls '["https://example.com"]' rtrvr raw crawl_and_extract_from_tab --user_input "Find all blog post titles" --tab_urls '["https://example.com/blog"]'

Scrape

CLI

rtrvr scrape https://example.com

实用工具

CLI

rtrvr devices rtrvr credits rtrvr profile

持续构建

同一套任务,可在多个入口复用:CLI、API、MCP 之间自由切换,无需重新学习任务契约。

你的下一次运行:随时随地运行

安装 CLI,即可从终端、CI 或其他 agent 中启动浏览器任务。

评论 (0)