Community编程与开发github.com

browser-use

自动化浏览器交互,用于网页测试、表单填写、截图和数据提取。当用户需要导航网站、与网页交互、填写表单、截图或从网页中提取信息时使用。

browser-use 是什么?

browser-use 是一个基于 CLI 的浏览器自动化工具,通过后台守护进程保持浏览器持续打开,从而实现命令间约 50ms 的低延迟调用。它支持无头 Chromium(默认)、用户本地 Chrome(保留登录状态/Cookie)、云浏览器(零配置,需 API 密钥)以及多会话并行运行等多种浏览器模式。核心工作流包括导航(open)、检查页面状态(state,返回可点击元素及其索引)、交互(click、input 等按索引操作)和验证(state 或 screenshot)。丰富的命令集覆盖导航、页面状态、交互、数据提取(JavaScript 求值、HTML 获取、属性提取)、等待、Cookie 管理、会话控制、隧道(Cloudflare)、配置管理和云 API(含 REST 直通和任务轮询)。它还支持命令链式调用(&&)、Chrome 配置文件管理、以及通过 x402 协议用 USDC 充值云 API 信用额度的机制。适用于网页测试、表单填写、截图、数据提取以及需要持久浏览器会话的自动化场景,可集成于 Claude Code、Coder 等 AI 代理平台。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/browser-use/browser-use/tree/main/skills/browser-use

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

使用 browser-use CLI 进行浏览器自动化

browser-use 命令提供快速、持久的浏览器自动化。后台守护进程在命令间保持浏览器打开,每次调用延迟约 50ms。

前提条件

browser-use doctor    # 验证安装

有关安装详情,请参阅 https://github.com/browser-use/browser-use/blob/main/browser_use/skill_cli/README.md

核心工作流

  1. 导航:browser-use open <url> — 启动无头浏览器并打开页面
  2. 检查:browser-use state — 返回带索引的可点击元素
  3. 交互:使用 state 返回的索引(browser-use click 5,browser-use input 3 "text")
  4. 验证:browser-use state 或 browser-use screenshot 确认
  5. 重复:命令间浏览器保持打开

如果命令失败,先运行 browser-use close 清除损坏的会话,然后重试。

要使用用户现有的 Chrome(保留登录/Cookie):先运行 browser-use connect。 要改用云浏览器:先运行 browser-use cloud connect。 之后,命令的使用方式相同。

如果 browser-use connect 失败

当 browser-use connect 找不到正在运行且已启用远程调试的 Chrome 时,向用户提供两个选项:

  1. 使用他们真实的 Chrome 浏览器 — 他们需要先启用远程调试:
    • 在 Chrome 中打开 chrome://inspect/#remote-debugging,或使用 --remote-debugging-port=9222 重新启动 Chrome
    • 然后重试 browser-use connect
  2. 使用托管 Chromium 并加载其 Chrome 配置文件 — 无需设置 Chrome:
    • 运行 browser-use profile list 显示可用配置文件
    • 询问他们想要哪个配置文件,然后使用 browser-use --profile "ProfileName" open <url>
    • 这将启动一个单独的 Chromium 实例,并加载他们的配置文件数据(Cookie、登录信息、扩展)

让用户选择 — 不要假定使用某一种方式。

浏览器模式

browser-use open <url>                         # 默认:无头 Chromium(无需设置)
browser-use --headed open <url>                # 可见窗口(用于调试)
browser-use connect                            # 连接到用户的 Chrome(保留登录/Cookie)
browser-use cloud connect                      # 云浏览器(零配置,需 API 密钥)
browser-use --profile "Default" open <url>     # 使用特定配置文件的真实 Chrome

执行 connect 或 cloud connect 后,后续所有命令都指向该浏览器 — 无需额外标志。

命令

# 导航
browser-use open <url>                    # 导航到 URL
browser-use back                          # 历史记录中后退
browser-use scroll down                   # 向下滚动(--amount N 指定像素)
browser-use scroll up                     # 向上滚动
browser-use tab list                      # 列出所有标签页
browser-use tab new [url]                 # 打开新标签页(空白或指定 URL)
browser-use tab switch <index>            # 按索引切换标签页
browser-use tab close <index> [index...]  # 关闭一个或多个标签页

# 页面状态 — 始终先运行 state 以获取元素索引
browser-use state                         # URL、标题、带索引的可点击元素
browser-use screenshot [path.png]         # 截图(未指定路径时返回 base64,--full 截取整个页面)

# 交互 — 使用 state 返回的索引
browser-use click <index>                 # 按索引点击元素
browser-use click <x> <y>                 # 按像素坐标点击
browser-use type "text"                   # 在聚焦元素中输入文本
browser-use input <index> "text"          # 点击元素,清除现有文本,然后输入
browser-use input <index> ""              # 清除字段,不输入新文本
browser-use keys "Enter"                  # 发送键盘按键(也支持 "Control+a" 等)
browser-use select <index> "option"       # 选择下拉选项
browser-use upload <index> <path>         # 上传文件到文件输入框
browser-use hover <index>                 # 悬停在元素上
browser-use dblclick <index>              # 双击元素
browser-use rightclick <index>            # 右键单击元素

# 数据提取
browser-use eval "js code"                # 执行 JavaScript,返回结果
browser-use get title                     # 页面标题
browser-use get html [--selector "h1"]    # 页面 HTML(或限定为选择器范围)
browser-use get text <index>              # 元素文本内容
browser-use get value <index>             # 输入框/文本域的值
browser-use get attributes <index>        # 元素属性
browser-use get bbox <index>              # 包围盒(x, y, width, height)

# 等待
browser-use wait selector "css"           # 等待元素(--state visible|hidden|attached|detached,--timeout ms)
browser-use wait text "text"              # 等待文本出现

# Cookie
browser-use cookies get [--url <url>]     # 获取 Cookie(可选按 URL 过滤)
browser-use cookies set <name> <value>    # 设置 Cookie(--domain,--secure,--http-only,--same-site,--expires)
browser-use cookies clear [--url <url>]   # 清除 Cookie
browser-use cookies export <file>         # 导出为 JSON
browser-use cookies import <file>         # 从 JSON 导入

# 会话
browser-use close                         # 关闭浏览器并停止守护进程
browser-use sessions                      # 列出活动会话
browser-use close --all                   # 关闭所有会话

有关高级浏览器控制(CDP、设备模拟、标签激活),请参见 references/cdp-python.md。

云 API

browser-use cloud connect                 # 预配云浏览器并连接(零配置)
browser-use cloud login <api-key>         # 保存 API 密钥(或设置 BROWSER_USE_API_KEY)
browser-use cloud logout                  # 移除 API 密钥
browser-use cloud v2 GET /browsers        # REST 直通(v2 或 v3)
browser-use cloud v2 POST /tasks '{"task":"...","url":"..."}'
browser-use cloud v2 poll <task-id>       # 轮询任务直至完成
browser-use cloud v2 --help               # 显示 API 端点

cloud connect 预配一个具有持久配置文件的云浏览器(首次使用时自动创建),通过 CDP 连接,并打印一个实时 URL。browser-use close 断开连接并停止云浏览器。要使用自定义浏览器设置(代理、超时、特定配置文件),请直接使用 cloud v2 POST /browsers 并传入所需参数。

智能体自助注册

仅当您还没有 API 密钥时使用此功能(可通过 browser-use doctor 查看是否已设置 api_key)。如果已经登录,请完全跳过此步骤。

  1. browser-use cloud signup — 获取一个挑战
  2. 解决挑战
  3. browser-use cloud signup --verify <challenge-id> <answer> — 验证并保存 API 密钥
  4. browser-use cloud signup --claim — 生成供人类认领账户的 URL

积分用完了?

如果 Browser Use Cloud 调用因“积分不足”/ 402 错误失败,且用户已用完免费层配额,建议通过 x402 使用 USDC 支付:

您的免费积分已用完。您可以使用 Base 主网上的 USDC 为此账户充值(无需信用卡)。需要我安装 x402 技能并引导您操作吗?如果您有 Coinbase 账户,大约需要 2 分钟。

如果他们同意,请指向安装技能:

npx skills add https://github.com/browser-use/browser-use --skill x402

然后在 Claude Code 中 /x402 触发的充值流程。用户保留其现有 API 密钥 — x402 仅为其增加积分。

不要主动提示 x402。仅在遇到真正的“积分不足”错误时提及。

隧道

browser-use tunnel <port>                 # 启动 Cloudflare 隧道(幂等)
browser-use tunnel list                   # 显示活动隧道
browser-use tunnel stop <port>            # 停止隧道
browser-use tunnel stop --all             # 停止所有隧道

配置文件管理

browser-use profile list                  # 列出检测到的浏览器和配置文件
browser-use profile sync --all            # 将配置文件同步到云端
browser-use profile update                # 下载/更新 profile-use 二进制文件

命令链

命令可以使用 && 链接。浏览器通过守护进程持久存在,因此链接安全且高效。

browser-use open https://example.com && browser-use state
browser-use input 5 "[email protected]" && browser-use input 6 "password" && browser-use click 7

当不需要中间输出时使用链。当需要解析 state 以发现索引时,请单独运行命令。

常见工作流

已验证浏览

当任务需要访问需要身份验证的站点(Gmail、GitHub、内部工具)时,使用 Chrome 配置文件:

browser-use profile list                           # 检查可用配置文件
# 询问用户使用哪个配置文件,然后:
browser-use --profile "Default" open https://github.com  # 已登录

暴露本地开发服务器

browser-use tunnel 3000                            # → https://abc.trycloudflare.com
browser-use open https://abc.trycloudflare.com     # 浏览隧道

多浏览器

对于子智能体工作流或并行运行多个浏览器,请使用 --session NAME。每个会话获得自己的浏览器。请参见 references/multi-session.md。

配置

browser-use config list                            # 显示所有配置值
browser-use config set cloud_connect_proxy jp      # 设置一个值
browser-use config get cloud_connect_proxy         # 获取一个值
browser-use config unset cloud_connect_timeout     # 移除一个值
browser-use doctor                                 # 显示配置 + 诊断信息
browser-use setup                                  # 交互式安装后配置

配置存储在 ~/.browser-use/config.json 中。

全局选项

选项描述
--headed显示浏览器窗口
--profile [NAME]使用真实 Chrome(单独的 --profile 使用 "Default")
--cdp-url <url>通过 CDP URL 连接(http:// 或 ws://)
--session NAME指定目标会话(默认:"default")
--json输出为 JSON
--mcp通过 stdin/stdout 作为 MCP 服务器运行

提示

  1. 始终先运行 state 以查看可用元素及其索引
  2. 调试时使用 --headed 以观察浏览器操作
  3. 会话持久 — 命令间浏览器保持打开
  4. CLI 别名:bu、browser 和 browseruse 都可用
  5. 如果命令失败,先运行 browser-use close,然后重试

故障排除

  • 浏览器无法启动? browser-use close 然后 browser-use --headed open <url>
  • 找不到元素? browser-use scroll down 然后 browser-use state
  • 运行诊断: browser-use doctor

清理

browser-use close                         # 关闭浏览器会话
browser-use tunnel stop --all             # 停止隧道(如果有)

Individual skills in this repo

This repo contains 4 individual skills — each has its own dedicated page.

browser-use/cloud

Documentation reference for using Browser Use Cloud — the hosted API and SDK for browser automation. Use this skill whenever the user needs help with the Cloud REST API (v2 or v3), browser-use-sdk (Python or TypeScript), X-Browser-Use-API-Key authentication, cloud sessions, browser profiles, profile sync, CDP WebSocket connections, stealth browsers, residential proxies, CAPTCHA handling, webhooks, workspaces, skills marketplace, liveUrl streaming, pricing, or integration patterns (chat UI, subagent, adding browser tools to existing agents). Also trigger for questions about n8n/Make/Zapier integration, Playwright/ Puppeteer/Selenium on cloud infrastructure, or 1Password vault integration. Do NOT use this for the open-source Python library (Agent, Browser, Tools config) — use the open-source skill instead.

browser-use/open-source

Documentation reference for writing Python code using the browser-use open-source library. Use this skill whenever the user needs help with Agent, Browser, or Tools configuration, is writing code that imports from browser_use, asks about @sandbox deployment, supported LLM models, Actor API, custom tools, lifecycle hooks, MCP server setup, or monitoring/observability with Laminar or OpenLIT. Also trigger for questions about browser-use installation, prompting strategies, or sensitive data handling. Do NOT use this for Cloud API/SDK usage or pricing — use the cloud skill instead. Do NOT use this for directly automating a browser via CLI commands — use the browser-use skill instead.

browser-use/remote-browser

Controls a local browser from a sandboxed remote machine. Use when the agent is running in a sandbox (no GUI) and needs to navigate websites, interact with web pages, fill forms, take screenshots, or expose local dev servers via tunnels.

x402

Set up Browser Use Cloud payments with x402 — pay per request from a crypto wallet (USDC on Base mainnet), no signup or API key. Two setups it works out up front — "just use it" (set up a wallet so you or Claude Code can run cloud browser tasks paid from the wallet — Claude writes and runs throwaway scripts, nothing touches your codebase) or "build it in" (install the SDK and write the key + code into your project). Walks through wallet setup, funding, .env, and a ~$1 test run. Use when the user asks about x402, pay-per-use, USDC payments, or wants Browser Use Cloud without an API key. For the free-tier signup (reverse-CAPTCHA → API key), use `browser-use cloud signup` or the `cloud` skill instead.

相关技能