mcpField
B
browser-use

browser-use

远程服务
browser-use.com浏览器自动化119.3k1 天前更新

关于 browser-use

browser-use 是用于自动化网页任务的开源浏览器 Agent,可通过 Python 库、CLI 或托管服务运行。它支持本地或云端浏览器,并提供适用于浏览器自动化的云端基础设施。

主要功能

  1. 01Python 和 TypeScript 浏览器 Agent
  2. 02CLI 自动化浏览器任务
  3. 03连接本地或云端浏览器
  4. 04云端隐身浏览器与代理
  5. 05CAPTCHA 处理与运行记录

适用场景

  1. 01自动填写表单并预订时段
  2. 02浏览网页并提取信息
  3. 03将浏览器操作接入现有 Agent

配置

远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。

服务地址https://api.browser-use.com/v3/mcp
一键复制安装命令
Claude CodeTerminal
Cursor.cursor/mcp.json
VS Code.vscode/mcp.json
Claude Desktopclaude_desktop_config.json
Windsurf~/.codeium/windsurf/mcp_config.json

命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。

全部服务地址
Streamable HTTPhttps://api.browser-use.com/v3/mcp需要授权
安装包
pypibrowser-use0.13.11

工具

2
参数类型必填说明
codestring是要执行的 Python 代码

详细介绍

浅色模式下显示黑色的 Browser Use Logo,深色模式下显示白色的 Logo。
AI 浏览器 Agent。
Browser-Use 软件包下载统计

演示 README 配图 文档 README 配图 博客 README 配图 周边商品 README 配图 Github 星标 README 配图 Twitter README 配图 Discord README 配图 Browser-Use 云服务

开源浏览器 Agent。可在本地搭配任意大模型运行,也可使用 Browser Use Cloud:具备隐身功能的浏览器每小时仅需 $0.02,在 Stealth Bench V2 上取得最高分(90.5%)。


像人类一样浏览网页。

查找可预约时段,选择日期和时间,处理 CAPTCHA,并预约驾驶考试。

Browser Use V4 预约驾驶考试

探索更多演示和提示词 ↗


**AI Agent 和爬虫:**请阅读 browser-use.com/llms.txt,了解产品概览(开源项目、Browser Harness、云浏览器、Agents API、定价);阅读 docs.browser-use.com/llms.txt,查看文档索引。Browser Use 是开源浏览器 Agent(支持 Python 和 TypeScript),提供每浏览器小时 $0.02 的云浏览器,具备隐身功能、CAPTCHA 求解和住宅代理,并提供托管 Agent API。

我需要哪种 Browser Use?

使用 Browser Use 的三种方式:托管的 V4 Agent、Browser Use CLI 或开源 Python 库。三者都可驱动云浏览器;CLI 和库还可驱动本地浏览器。

快速入门

路径 1:全托管云端

借助我们托管的 Agent、隐身浏览器,以及用于配置文件、录制和数据策略的基础设施,扩展浏览器自动化规模。

开始使用 API ↗

使用 Google、GitHub 或 Microsoft 注册的新用户可获得 $1 云端额度。


路径 2:CLI

将此提示词粘贴到 Claude Code、Codex、Hermes、OpenClaw 或你喜欢的 Agent 中。

Install or upgrade browser-use to the latest stable version with uv using Python 3.12, run `browser-use skill install` to register the skill, and connect it to my browser. If setup or connection fails, follow https://github.com/browser-use/browser-harness/blob/main/install.md.

路径 3:Python 库

通过 Python 在本地运行 Browser Use Agent,可自行选择模型以及本地或云端浏览器:

1. 安装 Browser Use(Python >= 3.11):

安装好 uv 后,如果要开始一个新项目,请先运行 uv init --python 3.12。

uv add browser-use

2. 将你的 OpenAI API 密钥添加到 .env:

# .env
OPENAI_API_KEY=your-key
# BROWSER_USE_API_KEY=your-key  # Optional: BU2 model or cloud browser

如需使用 Browser Use 的任一可选服务,请获取 Browser Use API 密钥。

3. 将以下内容保存为 agent.py:

import asyncio

from browser_use import Agent, Browser, ChatBrowserUse, ChatOpenAI
from dotenv import load_dotenv

load_dotenv()

async def main():
    llm = ChatOpenAI(model='gpt-5.6-luna', reasoning_effort='xhigh')
    # llm = ChatBrowserUse(model='bu-2-0')  # Use BU2 instead; requires BROWSER_USE_API_KEY
    agent = Agent(
        task="Find the number of stars of the browser-use repo",
        llm=llm,
        # browser=Browser(use_cloud=True),  # Use a cloud browser; requires BROWSER_USE_API_KEY
    )
    history = await agent.run()
    print(history.final_result())

if __name__ == "__main__":
    asyncio.run(main())

要使用 BU2,请将 ChatOpenAI 行替换为注释掉的 ChatBrowserUse 行。云浏览器选项可与任一模型搭配使用。

4. 运行:

uv run agent.py

Agent 会打开浏览器、查找代码库并打印答案。

5. 在云浏览器上运行同一个 Agent(无需安装 Chrome;可在 Docker、CI 和无服务器环境中使用):

设置 BROWSER_USE_API_KEY(获取密钥),然后取消 agent.py 中 browser= 行的注释并再次运行:

    agent = Agent(
        task="Find the number of stars of the browser-use repo",
        llm=llm,
        browser=Browser(use_cloud=True),
    )

云浏览器的费用为每浏览器小时 $0.02,另加网络流量费用(定价);此外还提供隐身功能、住宅代理、CAPTCHA 求解和实时查看 URL。代码不变,无需其他改动。

Python 库文档 ↗


# 面向 Claude 的 Browser Use 工具集

由 Browser Use 维护。兼容 Claude。

将 Browser Use 用作驱动,使用 Claude 的浏览器工具集。Browser Use 实现了全部 31 种浏览器操作,可控制本地浏览器、Browser Use Cloud 浏览器,或通过 CDP 控制现有远程浏览器。 Browser Use 集成中包含 Bash,可用于处理数据和编写文件。

Claude 通过 Anthropic SDK 使用 Browser Use 浏览器操作和 Bash。浏览器可以是本地或远程浏览器;Bash 在 SDK 主机上运行。

需要包含 anthropic.tools.browser 的 Anthropic SDK 版本。 Bash 需要使用 Linux 或 macOS 主机,并具备 /bin/bash;Windows 用户请使用 WSL。 下面的代码片段在异步函数中运行;完整脚本请参阅快速入门。

import os

from anthropic import AsyncAnthropic
from browser_use.integrations.toolsets_for_claude import Bash, BrowserUse

task = 'Open example.com and report its page title.'
driver = BrowserUse()  # Or BrowserUse(use_cloud=True)
bash = Bash(output_dir='outputs')

async with driver, AsyncAnthropic() as client:
    runner = client.beta.messages.tool_runner(
        model=os.environ['ANTHROPIC_MODEL'],
        max_tokens=32_768,
        max_iterations=100,
        tools=[driver, bash],
        messages=[{'role': 'user', 'content': task}],
    )
    result = await runner.until_done()

快速入门 ↗ · 集成文档 ↗


Browser Use Benchmark v2

Browser Use Benchmark v2 - 按模型划分的平均评分以及每项任务的成本

这项难度极高的基准测试针对最难的浏览器任务。对于较简单的任务,即使较小的模型也能取得很高的成功率。此处展示的结果来自 BU Bench V2 的 60 项任务子集。

集成、托管、自定义工具、MCP 等内容请参阅我们的文档 ↗


常见问题

我应该使用完全托管的云服务、CLI 还是 Python 库?
  • 完全托管的云服务: 通过 API 提交任务,由 Browser Use 运行 Agent、浏览器和基础设施。
  • CLI: 为现有 Agent(Claude Code、Codex、Hermes、OpenClaw、Pi、Cursor 等)提供浏览器访问权限。你可以交互式使用,也可以在脚本中使用。
  • Python 库: 在自己的应用中运行开源 Agent,并使用自定义工具、结构化输出以及自己选择的模型。

CLI 和 Python 库都可以连接本地或云端浏览器。云端浏览器托管浏览器;完全托管的 API 还会运行 Agent。

使用哪个模型最好?

我们推荐 BU2,这是为浏览器自动化优化的模型:ChatBrowserUse(model='bu-2-0')。它使用 BROWSER_USE_API_KEY;目前,ChatBrowserUse() 选择的也是同一模型。

最佳选择取决于你的任务、延迟要求和预算。请参阅 BU2 模型说明、基准测试以及支持的模型和定价,以比较各项选择。

我可以通过 ChatBrowserUse 使用 Claude / GPT / Gemini 吗?

可以。ChatBrowserUse 通过 Browser Use 网关接受带提供商前缀的模型 ID,并使用 BROWSER_USE_API_KEY:

from browser_use import Agent, ChatBrowserUse

llm = ChatBrowserUse(model='anthropic/claude-sonnet-4-6')  # or 'google/gemini-3-pro'
agent = Agent(task='...', llm=llm)

你也可以通过 ChatOpenAI、ChatAnthropic 和 ChatGoogle 等封装直接使用各提供商,并使用各自的 API 密钥。请参阅支持的模型。

我需要提供系统提示词吗? 不需要。`Agent(...)` 会自动提供 Browser Use 系统提示词,即使你更改模型也是如此。将任务写在 `task=` 中。需要自定义行为时,使用 `extend_system_message` 添加指令,或使用 `override_system_message` 替换默认提示词。

请参阅自定义系统提示词示例。

可以在 Agent 中使用自定义工具吗?

可以。使用 Tools 注册函数,然后将其传递给 Agent。此示例添加了一个获取当前 UTC 时间的工具,并使用 .env 中的 BROWSER_USE_API_KEY:

import asyncio
from datetime import datetime, timezone

from browser_use import ActionResult, Agent, ChatBrowserUse, Tools
from dotenv import load_dotenv

load_dotenv()
tools = Tools()

@tools.action(description='Get the current date and time in UTC.')
def get_current_time() -> ActionResult:
    return ActionResult(extracted_content=datetime.now(timezone.utc).isoformat())

async def main():
    agent = Agent(
        task="What is the current UTC time?",
        llm=ChatBrowserUse(model='bu-2-0'),
        tools=tools,
    )
    history = await agent.run()
    print(history.final_result())

if __name__ == "__main__":
    asyncio.run(main())
可以免费使用吗?

Python 库可免费使用,并采用 MIT 许可证。模型推理和托管浏览器需单独付费:API 提供商(包括 ChatBrowserUse)和 Browser Use Cloud 会按使用量收费。你也可以通过 Ollama 使用本地浏览器和本地模型,具体取决于你的硬件和模型要求。

服务条款

此开源库采用 MIT 许可证。有关 Browser Use 服务和数据政策,请参阅我们的服务条款和隐私政策。

如何处理身份验证?
  • 本地浏览器: 使用 Browser.from_system_chrome() 复用 Chrome 配置文件。请参阅真实浏览器指南和示例。
  • 云浏览器: 按照配置文件同步指南操作,然后使用 Browser(use_cloud=True, cloud_profile_id='your-profile-id')。

配置文件同步会传输 Cookie,但不会传输本地存储、IndexedDB 或扩展程序。某些网站可能会要求你重新登录。

如何解决 CAPTCHA?

Browser Use Cloud 提供隐身浏览器和代理,旨在降低机器人检测和 CAPTCHA 挑战的发生率。使用 Python 库时,通过 Browser(use_cloud=True) 启用云浏览器,并设置 BROWSER_USE_API_KEY。

结果取决于网站和挑战类型;任何浏览器配置都无法保证避开或解决所有 CAPTCHA。

如何用于生产环境?

根据你希望自行管理的内容选择方案:

  • 保留自己的 Agent 代码: 将 CLI 或 Python 库连接到云浏览器,使用托管浏览器基础设施、隐身功能、配置文件和录制功能。
  • 也由我们运行 Agent: 使用全托管 Cloud API提交任务并获取结果。

你也可以在自己的基础设施上托管 Python 库和浏览器。

可以在不每一步都调用模型的情况下重新运行任务吗?

可以。保存一次成功运行,然后用新值重放其中的点击和输入操作。以下代码片段在异步函数中运行:

from browser_use import Agent, ChatBrowserUse

llm = ChatBrowserUse()
agent = Agent(task='Open https://example.com/billing and request an invoice copy for Ada Lovelace, [email protected]', llm=llm)
await agent.run()
agent.save_history('invoice_run.json')
print(agent.detect_variables())  # names come from the form's fields, e.g. 'name' and 'email'

# Later: the same clicks and typing with new values, no model call per step
results = await Agent(task='', llm=llm).load_and_rerun(
    'invoice_run.json', variables={'name': 'Grace Hopper', 'email': '[email protected]'}, skip_failures=False
)
- 使用 `detect_variables()` 输出的变量名。未知名称会跳过并发出警告,改为输入记录的值。 - 提取步骤和结尾总结仍会调用模型。 - 如果页面发生变化,回放会在遇到无法匹配的第一步时引发 `RuntimeError`。此之前的步骤已经执行,因此再次运行 Agent 前,请检查表单是否已提交。 - 请将保存的文件设为私有。使用 `sensitive_data` 时,输入的机密会保存为 `key` 占位符,但页面快照和结果会按原样保存,仍可能包含这些机密。请为负责回放的 Agent 提供相同的 `sensitive_data`;否则会输入占位符文本。

示例


相关仓库

仓库用途
Browser Harness用于让 AI Agent 控制浏览器的命令行工具。
Browser Harness JS让你的 JavaScript Agent 控制真实浏览器。
Browser Use Pi运行基于 Pi 构建的 TypeScript 浏览器 Agent。
Cloud SDK将 Browser Use Cloud 集成到你的应用中。
Video Use使用你的编码 Agent 编辑视频。
macOS Harness让你的 Agent 控制 Mac 应用、浏览器和文件。
Benchmark探索浏览器任务并比较 Agent 性能。

引用

如果你在研究或项目中使用 Browser Use,请引用:

@software{browser_use2024,
  author = {Müller, Magnus and Žunič, Gregor},
  title = {Browser Use: Enable AI to control your browser},
  year = {2024},
  publisher = {GitHub},
  url = {https://github.com/browser-use/browser-use}
}

告诉你的计算机要做什么,它就会完成。

README 配图

Twitter Follow     Twitter Follow

在苏黎世和旧金山倾心打造 ❤️

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。