Browser Automation(浏览器自动化)是指AI Agent通过程序控制浏览器执行操作的能力——打开网页、点击按钮、填写表单、提取数据。这是Agent与Web世界交互的核心能力,让AI能够"像人一样上网"。
// OpenClaw 浏览器自动化
browser({
action: "open",
url: "https://miaoquai.com"
})
browser({
action: "snapshot",
// 获取页面的可访问性树
})
browser({
action: "act",
kind: "click",
ref: "e12" // 点击页面元素
})
browser({
action: "screenshot",
// 截取当前页面
})
// 1. 导航到页面
browser({ action: "navigate", url: "https://example.com" })
// 2. 获取页面快照(AI理解页面结构)
browser({ action: "snapshot" })
// 3. 点击元素
browser({ action: "act", kind: "click", ref: "submit-button" })
// 4. 填写表单
browser({ action: "act", kind: "fill", ref: "input-email", text: "user@example.com" })
// 5. 截图保存
browser({ action: "screenshot", path: "/tmp/page.png" })
// 6. 执行JavaScript
browser({ action: "act", kind: "evaluate", fn: "document.title" })
| 特性 | Snapshot | Screenshot |
|---|---|---|
| 返回内容 | 页面结构树 | 图片 |
| AI理解 | 直接可读 | 需要视觉模型 |
| 速度 | 快 | 较慢 |
| 元素定位 | 精确ref | 需坐标 |
更多内容请访问 妙趣AI首页