Camofox反检测浏览器 × AI Agent = 超级RPA
有些网站没有API,只有网页界面。这时候就需要浏览器自动化——让AI Agent像人一样操作浏览器,完成数据采集、表单填写、页面交互等任务。
| 场景 | 说明 | 工具 |
|---|---|---|
| 数据采集 | 抓取网页内容、价格、评论 | camofox_snapshot |
| 表单填写 | 自动登录、提交表单 | camofox_type |
| 页面交互 | 点击按钮、滚动页面 | camofox_click |
| 截图监控 | 定期截图对比变化 | camofox_screenshot |
| RPA工作流 | 复杂的多步骤自动化 | 组合使用 |
// 创建新标签页并打开网页
const tab = await camofox_create_tab({
url: "https://example.com"
});
// 返回 tabId: "t1"
// 获取页面可访问性快照(推荐)
const snapshot = await camofox_snapshot({
tabId: "t1"
});
// 返回元素引用列表,如 e1, e2, e3...
// 点击元素
await camofox_click({ tabId: "t1", ref: "e5" });
// 输入文本
await camofox_type({
tabId: "t1",
ref: "e3",
text: "搜索关键词"
});
// 滚动页面
await camofox_scroll({
tabId: "t1",
direction: "down",
amount: 500
});
// 获取页面结构化数据
const result = await camofox_snapshot({
tabId: "t1",
offset: 0 // 分页偏移量
});
// 返回格式:
{
refs: [
{ ref: "e1", role: "heading", name: "标题", level: 1 },
{ ref: "e2", role: "link", name: "链接文字", url: "..." },
{ ref: "e3", role: "textbox", name: "搜索框" }
],
hasMore: false
}
// 在页面上下文中执行JS
const result = await camofox_evaluate({
tabId: "t1",
expression: `
document.querySelectorAll('.product-price')
.map(el => el.textContent)
`
});
// 返回价格列表
// 使用预设搜索宏
await camofox_navigate({
tabId: "t1",
macro: "@google_search",
query: "OpenClaw tutorial"
});
// 支持的搜索宏:
// @google_search - Google搜索
// @youtube_search - YouTube搜索
// @amazon_search - Amazon搜索
// @reddit_search - Reddit搜索
// @wikipedia_search - Wikipedia搜索
// 1. 打开竞品网站
const tab = await camofox_create_tab({
url: "https://competitor.com/pricing"
});
// 2. 等待页面加载
await new Promise(r => setTimeout(r, 2000));
// 3. 获取页面快照
const snapshot = await camofox_snapshot({ tabId: tab.tabId });
// 4. 提取价格数据
const prices = await camofox_evaluate({
tabId: tab.tabId,
expression: `
Array.from(document.querySelectorAll('.plan-price'))
.map(el => ({
plan: el.closest('.plan').querySelector('.plan-name').textContent,
price: el.textContent
}))
`
});
// 5. 截图保存证据
await camofox_screenshot({ tabId: tab.tabId });
// 6. 关闭标签页
await camofox_close_tab({ tabId: tab.tabId });