Writing Skills
writing-skills
效率与协作技能,来自 obra/superpowers,查看原文获取完整用途和操作说明。
smart-web-scraper【部署与运维】基于 Playwright 智能爬取网页内容,内置绕过 Cloudflare 等反爬机制的能力,提供简单模式和隐身模式两种方案以应对不同反爬强度,输出网页标题、文本内容和截图。当用户需要抓取动态网页、获取被保护网站的数据,或提到爬虫、反爬虫、Cloudflare、网页截图、JavaScript渲染等关键词时触发。
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
基于 Playwright 的网页爬取 OpenClaw Skill,内置反爬虫保护机制。可根据目标网站的反爬级别选择最佳方案。
| 目标网站 | 反爬级别 | 推荐方案 | 脚本 |
|---|---|---|---|
| 普通网站 | 低 | web_fetch 工具 | 无需脚本(内置) |
| 动态网站 | 中 | Playwright 简单模式 | scripts/playwright-simple.js |
| Cloudflare 防护网站 | 高 | Playwright 隐身模式 ⭐ | scripts/playwright-stealth.js |
| YouTube | 特殊 | deep-scraper | 需单独安装 |
| 特殊 | reddit-scraper | 需单独安装 |
cd playwright-scraper-skill
npm install
npx playwright install chromium
使用 OpenClaw 内置的 web_fetch 工具:
# Invoke directly in OpenClaw
Hey, fetch me the content from https://example.com
使用 Playwright 简单模式:
node scripts/playwright-simple.js "https://example.com"
示例输出:
{
"url": "https://example.com",
"title": "Example Domain",
"content": "...",
"elapsedSeconds": "3.45"
}
使用 Playwright 隐身模式:
node scripts/playwright-stealth.js "https://m.discuss.com.hk/#hot"
功能特性:
navigator.webdriver = false)使用 deep-scraper(需单独安装):
# Install deep-scraper skill
npx clawhub install deep-scraper
# Use it
cd skills/deep-scraper
node assets/youtube_handler.js "https://www.youtube.com/watch?v=VIDEO_ID"
scripts/playwright-simple.jsscripts/playwright-stealth.js ⭐如果网站没有动态加载,使用 OpenClaw 内置的 web_fetch 工具——速度最快。
如果需要等待 JavaScript 渲染完成,使用 playwright-simple.js。
如果遇到 403 错误或 Cloudflare 验证,使用 playwright-stealth.js。
所有脚本支持通过环境变量配置:
# Set screenshot path
SCREENSHOT_PATH=/path/to/screenshot.png node scripts/playwright-stealth.js URL
# Set wait time (milliseconds)
WAIT_TIME=10000 node scripts/playwright-simple.js URL
# Enable headful mode (show browser)
HEADLESS=false node scripts/playwright-stealth.js URL
# Save HTML
SAVE_HTML=true node scripts/playwright-stealth.js URL
# Custom User-Agent
USER_AGENT="Mozilla/5.0 ..." node scripts/playwright-stealth.js URL
| 方案 | 速度 | 反爬能力 | 成功率(Discuss.com.hk) |
|---|---|---|---|
| web_fetch | ⚡ 最快 | ❌ 无 | 0% |
| Playwright 简单模式 | 🚀 快 | ⚠️ 低 | 20% |
| Playwright 隐身模式 | ⏱️ 中等 | ✅ 中等 | 100% ✅ |
| Puppeteer 隐身模式 | ⏱️ 中等 | ✅ 中高 | ~80% |
| Crawlee (deep-scraper) | 🐢 慢 | ❌ 被检测 | 0% |
| Chaser (Rust) | ⏱️ 中等 | ❌ 被检测 | 0% |
从测试中总结的经验:
navigator.webdriver — 必不可少addInitScript(Playwright) — 在页面加载前注入脚本解决方案: 使用 playwright-stealth.js
解决方案:
headless: false(有头模式有时成功率更高)解决方案:
waitForTimeout 时间waitUntil: 'networkidle' 或 'domcontentloaded'最佳方案: 纯 Playwright + 反爬技术(不依赖特定框架)
browser 工具集成