SuperAPI AI Directory

browser-use

Frontend & websites

View repository

Updated 10-15 17:26

About this skill

Browser-Use CLI — Browser Automation

Control the browser via the browser-use command-line tool, with support for persistent sessions (~50ms latency), multiple parallel sessions, cloud browsers, local tunnels, and more.

Installation

The installation script will automatically install a Python virtual environment,browser-use package, Playwright, and Chromium, with no need to manually install Playwright or Selenium.

macOS / Linux

curl -fsSL https://browser-use.com/cli/install.sh | bash

Windows(Git Bash must be installed first:winget install Git.Git)

# 在 Git Bash 中运行
curl -fsSL https://browser-use.com/cli/install.sh | bash

Verify after installation

browser-use doctor

For detailed installation steps for the three platforms, prerequisites, and troubleshooting, see references/setup.md。

Standard Workflow

The browser runs persistently between commands, with no need to restart each time.

1. Open a web page

browser-use open https://example.com

2. View page state (get interactive elements and indices)

browser-use state
# 返回 URL、标题、所有可点击元素及其索引号

3. Interact

# 点击元素(使用 state 返回的索引号)
browser-use click 5

# 在输入框中输入文字(点击 + 输入)
browser-use input 3 "搜索内容"

# 通用打字(输入到当前焦点元素)
browser-use type "Hello World"

# 滚动页面
browser-use scroll down
browser-use scroll up
browser-use scroll down --amount 1000

# 悬停 / 双击 / 右键
browser-use hover 7
browser-use dblclick 4
browser-use rightclick 2

# 键盘按键
browser-use keys Enter
browser-use keys "Control+a"

# 下拉框选择
browser-use select 4 "option-value"

# 上传文件
browser-use upload 6 /path/to/file.pdf

4. Get data

# 截图
browser-use screenshot page.png
browser-use screenshot --full fullpage.png

# 执行 JavaScript 获取数据
browser-use eval "document.title"
browser-use eval "Array.from(document.querySelectorAll('h2')).map(h=>h.textContent)"

# 获取元素信息
browser-use get title
browser-use get html
browser-use get html --selector "main"
browser-use get text 5
browser-use get value 3
browser-use get attributes 2
browser-use get bbox 4

5. Wait for conditions

browser-use wait selector ".loading" --state hidden
browser-use wait text "Success"
browser-use wait selector "h1" --timeout 5000

6. Page navigation

browser-use back
browser-use tab list
browser-use tab new https://example.com
browser-use tab switch 2
browser-use tab close

7. End

browser-use close
browser-use close --all

Global Options

Option Description
--headed Show the browser window (headless mode by default)
--profile [NAME] Use the real Chrome profile (preserve login state, cookies)
--connect Automatically connect to an already running Chrome
--cdp-url <url> Connect to the browser via a CDP URL
--session NAME Named session (supports multiple parallel browsers)
--json Output in JSON format
--mcp Run in MCP server mode

Use the real Chrome profile

# 使用 Default 配置,已登录的网站无需重新登录
browser-use --profile open https://mail.google.com

# 使用指定 Chrome 配置
browser-use --profile "Profile 1" open https://example.com

Multiple parallel sessions

# 启动两个独立的浏览器会话
browser-use --session work open https://app.example.com
browser-use --session personal open https://social.example.com

# 分别操作
browser-use --session work click 3
browser-use --session personal type "hello"

# 查看活跃会话
browser-use sessions

Cookie management

browser-use cookies get
browser-use cookies get --url https://example.com
browser-use cookies set token abc123 --domain .example.com --secure
browser-use cookies export cookies.json
browser-use cookies import cookies.json
browser-use cookies clear

Python automation scripts

# 执行 Python(持久会话,变量跨命令保留)
browser-use python "
for i in range(5):
    browser.scroll('down')
    browser.wait(0.5)
"

# 运行 Python 文件
browser-use python --file script.py

# 查看已定义变量
browser-use python --vars

Cloud browser

# 保存 API key
browser-use cloud login <browser-use-api-key>

# 启动云浏览器
browser-use cloud connect

# 创建自动化任务
browser-use cloud v2 POST /tasks '{"task":"搜索 AI 新闻","url":"https://google.com"}'

Local tunnel (expose local services)

# 将本地 3000 端口暴露到公网
browser-use tunnel 3000
# → 返回公网 URL,可供云浏览器访问

browser-use tunnel list
browser-use tunnel stop 3000

Typical Use Cases

Web data collection

browser-use open https://news.ycombinator.com
browser-use eval "JSON.stringify([...document.querySelectorAll('.titleline a')].map(a=>({title:a.textContent,href:a.href})).slice(0,10))"
browser-use close

Form filling

browser-use open https://example.com/signup
browser-use state                       # 找到表单元素索引
browser-use input 2 "user@example.com"
browser-use input 3 "password123"
browser-use click 5                     # 点击提交
browser-use screenshot result.png
browser-use close

Search and screenshot

browser-use open https://www.google.com
browser-use state
browser-use input 2 "browser-use github"
browser-use keys Enter
browser-use screenshot search.png
browser-use close

Troubleshooting

Issue Solution
Chromium not found browser-use install
Page load timeout Use the wait command or check the network
Incorrect element index Re-run state to get the latest index
Login state required Use the --profile option
Windows ARM64 Install the x64 version of Python (via emulation)
Daemon error taskkill /IM python.exe /F(Windows)