🦊 OpenClaw Camofox 网页自动化实战

反检测浏览器 | RPA | 人类行为模拟

📌 什么是 Camofox?

Camofox 是 OpenClaw 内置的反检测浏览器自动化工具。它可以模拟人类行为,绕过网站的反爬虫机制,实现真正的网页自动化。

🛡️ 反检测

内置反指纹检测,绕过 Cloudflare、reCAPTCHA 等防护。

👤 人类行为模拟

模拟鼠标移动、点击、滚动等人类行为。

📸 截图和快照

支持页面截图、DOM 快照、元素定位。

🔧 丰富的 API

提供点击、输入、滚动、导航等完整 API。

🚀 快速开始

1. 创建浏览器标签

# 使用 Camofox 创建标签
openclaw camofox create-tab https://example.com

# 列出所有标签
openclaw camofox list-tabs

2. 获取页面快照

# 获取页面快照
openclaw camofox snapshot tab1

# 输出包含元素引用(e1, e2, e3...)
# 可以使用这些引用进行交互

3. 与页面交互

# 点击元素
openclaw camofox click tab1 --ref e5

# 输入文本
openclaw camofox type tab1 --ref e3 --text "Hello World"

# 滚动页面
openclaw camofox scroll tab1 --direction down --amount 500

🎯 常见场景

场景1:登录网站

# 1. 创建标签并导航到登录页
openclaw camofox create-tab https://example.com/login

# 2. 获取快照找到输入框
openclaw camofox snapshot tab1

# 3. 输入用户名和密码
openclaw camofox type tab1 --ref e3 --text "username"
openclaw camofox type tab1 --ref e5 --text "password"

# 4. 点击登录按钮
openclaw camofox click tab1 --ref e7

场景2:数据抓取

# 1. 导航到目标页面
openclaw camofox navigate tab1 https://example.com/data

# 2. 滚动加载更多内容
openclaw camofox scroll tab1 --direction down --amount 1000

# 3. 提取数据
openclaw camofox evaluate tab1 "
    const items = document.querySelectorAll('.item');
    return Array.from(items).map(item => ({
        title: item.querySelector('h2').textContent,
        link: item.querySelector('a').href
    }));
"

场景3:表单提交

# 1. 导航到表单页面
openclaw camofox navigate tab1 https://example.com/form

# 2. 填写表单
openclaw camofox type tab1 --ref e3 --text "张三"
openclaw camofox type tab1 --ref e5 --text "zhangsan@example.com"
openclaw camofox select tab1 --ref e7 --value "option1"

# 3. 提交表单
openclaw camofox click tab1 --ref e9

🔧 高级功能

1. 执行 JavaScript

# 在页面中执行 JavaScript
openclaw camofox evaluate tab1 "
    document.title = 'New Title';
    return document.title;
"

2. 截图

# 截取整个页面
openclaw camofox screenshot tab1 --output /tmp/screenshot.png

# 截取特定元素
openclaw camofox screenshot tab1 --ref e5 --output /tmp/element.png

3. 等待元素

# 等待元素出现
openclaw camofox wait tab1 --ref e5 --timeout 10000

# 等待页面加载
openclaw camofox wait tab1 --load-state networkidle
💡 提示:使用 Camofox 时,建议添加适当的延迟(delayMs),模拟人类操作节奏,避免被检测为机器人。

🎯 最佳实践

1. 模拟人类行为

# 使用 slowly 参数模拟慢速输入
openclaw camofox type tab1 --ref e3 --text "Hello" --slowly true

# 添加延迟
openclaw camofox click tab1 --ref e5 --delayMs 500

2. 错误处理

# 检查元素是否存在
openclaw camofox snapshot tab1 | grep "e5"

# 使用 try-catch 处理错误
openclaw camofox evaluate tab1 "
    try {
        const element = document.querySelector('.target');
        return element.textContent;
    } catch (e) {
        return 'Element not found';
    }
"

3. 资源管理

# 关闭不需要的标签
openclaw camofox close-tab tab1

# 查看标签状态
openclaw camofox list-tabs

🔗 相关资源

🦊 开始网页自动化

使用 Camofox 让你的 Agent 无缝操作网页,实现真正的自动化。

访问 ClawHub → | GitHub 仓库 →