Community程式設計與開發github.com

browser-use

自動化瀏覽器操作,用於網頁測試、表單填寫、螢幕截圖和資料擷取。當使用者需要瀏覽網站、與網頁互動、填寫表單、截圖或從網頁中提取資訊時使用。

browser-use 是什麼?

browser-use 是一個基於 CLI 的瀏覽器自動化技能,透過背景常駐程式(daemon)讓瀏覽器在多次指令間保持開啟,每次呼叫的延遲僅約 50 毫秒。它支援無頭(headless)、有頭(headed)模式、連接到使用者真實 Chrome 瀏覽器(保留登入狀態與 Cookie),以及雲端瀏覽器等多種模式。使用者可以導航、點擊、輸入、選取下拉選單、上傳檔案、執行 JavaScript、擷取螢幕截圖或提取元素文字與屬性。此技能也內建雲端 API、Tunnel 通道與設定檔管理,適合 AI 代理在網頁測試、資料爬取與自動化工作流程中使用。支援 `&&` 指令串聯與多 session 平行執行,並提供代理自我註冊與 USDC 付費機制。

相容平台✓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 指令提供快速、持久的瀏覽器自動化。背景常駐程式會讓瀏覽器在多個指令之間保持開啟,每次呼叫的延遲約為 50 毫秒。

先決條件

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。\n執行上述任一指令後,後續指令的運作方式相同。

如果 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(可選過濾)
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以 MCP 伺服器方式透過 stdin/stdout 執行

提示

  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.

相關技能