运行时依赖
安装命令
点击复制技能文档
Browser 自动化 with browser-use 命令行工具
The browser-use command provides fast, persistent browser 自动化. A background daemon keeps the browser open across commands, giving ~50ms latency per call.
Prerequisites browser-use doctor # 验证 安装ation
For 设置up detAIls, see https://github.com/browser-use/browser-use/blob/mAIn/browser_use/技能_命令行工具/README.md
Core 工作流 Navigate: browser-use open — 启动s browser if needed Inspect: browser-use 状态 — returns 命令行工具ckable elements with indices Interact: use indices from 状态 (browser-use 命令行工具ck 5, browser-use 输入 3 "text") 验证: browser-use 状态 or browser-use screenshot to confirm Repeat: browser stays open between commands 清理up: browser-use close when done Browser Modes browser-use open # Default: headless Chromium browser-use --headed open # Visible window browser-use --性能分析 "Default" open # Real Chrome with Default 性能分析 (existing 记录ins/cookies) browser-use --性能分析 "性能分析 1" open # Real Chrome with named 性能分析 browser-use --connect open # Auto-discover 运行ning Chrome via CDP browser-use --cdp-url ws://localhost:9222/... open # Connect via CDP URL
--connect, --cdp-url, and --性能分析 are mutually exclusive.
Commands # Navigation browser-use open # Navigate to URL browser-use back # Go back in 历史 browser-use scroll down # Scroll down (--amount N for pixels) browser-use scroll up # Scroll up browser-use switch # Switch to tab by 索引 browser-use close-tab [tab] # Close tab (current if no 索引)
# Page 状态 — always 运行 状态 first to 获取 element indices browser-use 状态 # URL, title, 命令行工具ckable elements with indices browser-use screenshot [path.png] # Screenshot (base64 if no path, --full for full page)
# Interactions — use indices from 状态 browser-use 命令行工具ck <索引> # 命令行工具ck element by 索引 browser-use 命令行工具ck # 命令行工具ck at pixel coordinates browser-use type "text" # Type into focused element browser-use 输入 <索引> "text" # 命令行工具ck element, then type browser-use keys "Enter" # 发送 keyboard keys (also "Control+a", etc.) browser-use select <索引> "option" # Select dropdown option browser-use 上传 <索引> # 上传 file to file 输入 browser-use hover <索引> # Hover over element browser-use dbl命令行工具ck <索引> # Double-命令行工具ck element browser-use right命令行工具ck <索引> # Right-命令行工具ck element
# Data 提取ion browser-use eval "js code" # 执行 JavaScript, return 结果 browser-use 获取 title # Page title browser-use 获取 html [--selector "h1"] # Page HTML (or scoped to selector) browser-use 获取 text <索引> # Element text content browser-use 获取 value <索引> # 输入/textarea value browser-use 获取 attributes <索引> # Element attributes browser-use 获取 bbox <索引> # Bounding box (x, y, width, height)
# WAIt browser-use wAIt selector "css" # WAIt for element (--状态 visible|hidden|attached|detached, --timeout ms) browser-use wAIt text "text" # WAIt for text to 应用ear
# Cookies browser-use cookies 获取 [--url ] # 获取 cookies (optionally 过滤器ed) browser-use cookies 设置 # 设置 cookie (--domAIn, --安全, --http-only, --same-site, --expires) browser-use cookies clear [--url ] # Clear cookies browser-use cookies 导出 # 导出 to JSON browser-use cookies 导入 # 导入 from JSON
# Python — persistent 会话 with browser 访问 browser-use python "code" # 执行 Python (variables persist across calls) browser-use python --file script.py # 运行 file browser-use python --vars # Show defined variables browser-use python --re设置 # Clear namespace
# 会话 browser-use close # Close browser and 停止 daemon browser-use 会话s # 列出 active 会话s browser-use close --all # Close all 会话s
The Python browser object provides: browser.url, browser.title, browser.html, browser.goto(url), browser.back(), browser.命令行工具ck(索引), browser.type(text), browser.输入(索引, text), browser.keys(keys), browser.上传(索引, path), browser.screenshot(path), browser.scroll(direction, amount), browser.wAIt(seconds).
Cloud API browser-use cloud connect # Provision cloud browser and connect browser-use cloud connect --timeout 120 --proxy-country US # With options browser-use cloud 记录in # Save API key (or 设置 BROWSER_USE_API_KEY) browser-use cloud 记录out # 移除 API key browser-use cloud v2 获取 /browsers