Stagehand:Browserbase 出品的 AI 原生 Playwright 自动化 SDK

2026-06-15 23:00:00

Stagehand 开源项目分析

仓库:github.com/browserbase/stagehand · 文档:docs.stagehand.dev · License: MIT · ⭐ 5k+(快速增长)

项目是什么

StagehandBrowserbase 开源的 AI 原生浏览器自动化 SDK——底层 Playwright,上层提供 自然语言 + 结构化提取 API。

三大原语

API 作用
act() 自然语言执行动作(「点击导航栏 New 链接」)
extract() Zod Schema 结构化抽取
observe() 发现页面上可执行操作

示例

import { Stagehand } from '@browserbasehq/stagehand';

const stagehand = new Stagehand({ env: 'LOCAL', modelName: 'gpt-4o' });
await stagehand.init();
await stagehand.page.goto('https://news.ycombinator.com');
await stagehand.page.act('click on the "new" link');
const data = await stagehand.page.extract({
  instruction: 'Extract top 5 story titles',
  schema: z.object({ stories: z.array(z.object({ title: z.string() })) }),
});

与 Browser Use / Firecrawl 差异

项目 模式
Browser Use 全自动 Agent 操控浏览器
Firecrawl API 返回 Markdown,无浏览器脚本
Stagehand 开发者写脚本 + AI 填灵活部分

黑豹点评

Stagehand 适合 「80% Playwright 确定性 + 20% AI 处理 UI 变化」 的生产爬虫/自动化——比纯 Agent 更可控,比纯 Playwright 更省维护

项目链接https://github.com/browserbase/stagehand