凌晨3点,你的爬虫脚本又挂了。不是因为代码bug,而是因为目标网站检测到你在用自动化工具——这就是浏览器指纹检测的威力。
CloakBrowser(以及OpenClaw内置的Camofox)是一种「隐身浏览器」,它在源码级别修改Chromium,让自动化脚本看起来像真实用户操作:
OpenClaw内置Camofox反检测浏览器,提供完整的自动化接口:
{
"name": "camofox_create_tab",
"arguments": {
"url": "https://example.com"
}
}
// 返回
{
"tabId": "tab_abc123",
"status": "created"
}
{
"name": "camofox_snapshot",
"arguments": {
"tabId": "tab_abc123"
}
}
// 返回页面DOM和元素引用
{
"snapshot": "...",
"refs": {
"e1": {"type": "button", "text": "登录"},
"e2": {"type": "input", "name": "username"}
}
}
// 点击元素
{
"name": "camofox_click",
"arguments": {
"tabId": "tab_abc123",
"ref": "e1"
}
}
// 输入文本(带人类行为模拟)
{
"name": "camofox_type",
"arguments": {
"tabId": "tab_abc123",
"ref": "e2",
"text": "username",
"humanize": true // 随机延迟、拼写速度
}
}
# SKILL.md - 反检测爬虫技能
name: stealth_scraper
description: 使用Camofox进行反检测数据采集
workflow:
- step: create_browser
action: camofox_create_tab
args:
url: "${target_url}"
- step: wait_load
action: camofox_snapshot
args:
tabId: "$[0].tabId"
- step: extract_data
action: camofox_evaluate
args:
tabId: "$[0].tabId"
expression: |
Array.from(document.querySelectorAll('article'))
.map(el => ({
title: el.querySelector('h2')?.textContent,
link: el.querySelector('a')?.href
}))
- step: pagination
action: camofox_click
args:
tabId: "$[0].tabId"
ref: "next_page_button"
- step: close
action: camofox_close_tab
args:
tabId: "$[0].tabId"
// 普通浏览器会被检测
navigator.webdriver === true // ❌ 自动化标识
// Camofox已处理
navigator.webdriver === undefined // ✅ 正常浏览器行为
// Camofox自动保证指纹一致性
{
"userAgent": "Chrome/120.0.0.0",
"platform": "Win32",
"language": "en-US",
"timezone": "America/New_York",
"screen": {
"width": 1920,
"height": 1080,
"colorDepth": 24
},
"webgl": {
"vendor": "Google Inc.",
"renderer": "ANGLE..."
}
// 所有指纹相互匹配,不会出现矛盾
}
{
"name": "camofox_create_tab",
"arguments": {
"url": "https://example.com",
"proxy": {
"server": "socks5://localhost:1080",
"username": "user",
"password": "pass"
}
}
}
// 导入已有Cookie
{
"name": "camofox_import_cookies",
"arguments": {
"cookiesPath": "/path/to/cookies.txt",
"domainSuffix": ".linkedin.com"
}
}
// 格式:Netscape cookies.txt
// .linkedin.com TRUE / FALSE 0 li_at xxx
// 截图
{
"name": "camofox_screenshot",
"arguments": {
"tabId": "tab_abc123"
}
}
// 执行JavaScript
{
"name": "camofox_evaluate",
"arguments": {
"tabId": "tab_abc123",
"expression": "document.title"
}
}
// 不要短时间大量请求
const delay = Math.random() * 3000 + 2000; // 2-5秒随机延迟
await sleep(delay);
// 使用代理轮换
const proxies = ['proxy1:8080', 'proxy2:8080', 'proxy3:8080'];
const proxy = proxies[Math.floor(Math.random() * proxies.length)];
// 复用登录态,避免频繁登录
// 1. 首次登录后保存Cookie
// 2. 后续请求导入Cookie
// 3. Cookie过期前刷新
try {
const snapshot = await camofox_snapshot(tabId);
// 处理页面
} catch (error) {
if (error.code === 'DETECTED') {
// 被检测,更换指纹或代理
await rotateProfile();
} else if (error.code === 'TIMEOUT') {
// 页面超时,可能是网络问题
await retry();
}
}