WebScraper Skill
Extract and parse content from web pages into readable markdown or plain text.
When to Use
✅ USE this skill when:
- - "Read this article: [URL]"
- "What does this page say?"
- "Get the content from [URL]"
- Fetch documentation, blog posts, news articles
- Extract product information from e-commerce sites
- Grab API documentation or tutorials
- Summarize web page content
When NOT to Use
❌ DON'T use this skill when:
- - Login-required pages (use BrowserAgent with session)
- Heavy JavaScript-rendered content (use BrowserAgent)
- Interactive web apps (dashboards, SPAs)
- CAPTCHA-protected sites
- Sites with strict anti-bot measures
- Real-time data (stock tickers, live scores)
Commands
Fetch URL Content
CODEBLOCK0
Using curl (fallback)
CODEBLOCK1
Using Node.js (advanced)
CODEBLOCK2
Response Format
When fetching content, structure responses as:
CODEBLOCK3
Best Practices
1. Respect Rate Limits
CODEBLOCK4
2. Use Proper User-Agent
CODEBLOCK5
3. Handle Errors
CODEBLOCK6
4. Extract Specific Content
CODEBLOCK7
Integration with OpenClaw
Using web_fetch Tool
CODEBLOCK8
Batch Processing
For multiple URLs, process sequentially with delays:
CODEBLOCK9
Common Use Cases
1. Article Summarization
CODEBLOCK10
2. Product Information
CODEBLOCK11
3. Documentation Lookup
CODEBLOCK12
Troubleshooting
| Problem | Solution |
|---|
| Content empty/missing | Site uses JS rendering → use BrowserAgent |
| Blocked by site |
Add User-Agent, add delay, use proxy |
| Timeout | Increase timeout, check URL validity |
| Garbled text | Check charset, try text mode |
| Login required | Use BrowserAgent with session cookies |
Related Skills
- - BrowserAgent - For interactive/JS-heavy sites
- web_search - For finding URLs before fetching
- coding-agent - For processing extracted data
Security Notes
⚠️ Important:
- - Respect robots.txt
- Don't scrape personal data
- Honor copyright/terms of service
- Add delays between requests (2-5s)
- Don't overload servers
- Use official APIs when available
WebScraper 技能
从网页中提取并解析内容,转换为可读的 Markdown 或纯文本格式。
使用时机
✅ 使用此技能的场景:
- - 阅读这篇文章:[URL]
- 这个页面说了什么?
- 获取 [URL] 的内容
- 获取文档、博客文章、新闻文章
- 从电商网站提取产品信息
- 抓取 API 文档或教程
- 总结网页内容
不应使用的场景
❌ 不要使用此技能的场景:
- - 需要登录的页面(请使用带会话的 BrowserAgent)
- 重度 JavaScript 渲染的内容(请使用 BrowserAgent)
- 交互式 Web 应用(仪表盘、单页应用)
- 受 CAPTCHA 保护的网站
- 具有严格反爬虫措施的网站
- 实时数据(股票行情、实时比分)
命令
获取 URL 内容
bash
使用 OpenClaw web_fetch 工具(推荐)
通过工具调用,而非直接命令行
基本获取(Markdown 输出)
web_fetch(url: https://example.com/article)
纯文本模式(无 Markdown)
web_fetch(url: https://example.com/article, extractMode: text)
限制内容长度
web_fetch(url: https://example.com/article, maxChars: 5000)
使用 curl(备用方案)
bash
简单 HTML 获取
curl -s https://example.com | html2text -width 80
带 User-Agent(避免被识别为爬虫)
curl -s -A Mozilla/5.0 (Macintosh; Intel Mac OS X 10
157) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 https://example.com
获取并提取主要内容(需要 readability-cli)
curl -s https://example.com | readability
仅获取标题
curl -s https://example.com | grep -oP (?<=
).*?(?=)
使用 Node.js(高级)
bash
安装 cheerio 用于 HTML 解析
npm install -g cheerio
使用 Node 解析 HTML
node -e
const cheerio = require(cheerio);
const html = \\$(curl -s https://example.com)\;
const \$ = cheerio.load(html);
console.log(\$(article).text());
响应格式
获取内容时,按以下结构组织响应:
markdown
📄 [页面标题]
来源: URL
获取时间: 2026-03-20
内容
[提取的内容在此...]
摘要:[1-2 句摘要(如有帮助)]
最佳实践
1. 遵守速率限制
bash
在请求之间添加延迟
sleep 2 && curl https://example.com/page1
sleep 2 && curl https://example.com/page2
2. 使用合适的 User-Agent
bash
桌面版 Chrome
curl -A Mozilla/5.0 (Macintosh; Intel Mac OS X 10
157) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
移动版 Safari
curl -A Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1
3. 处理错误
bash
检查 HTTP 状态码
curl -s -o /dev/null -w %{http_code} https://example.com
10 秒超时
curl -s --max-time 10 https://example.com
失败时重试
curl -s --retry 3 https://example.com
4. 提取特定内容
bash
获取所有链接
curl -s https://example.com | grep -oP href=\K[^]+ | head -20
获取图片
curl -s https://example.com | grep -oP src=\K[^]+\.(jpg|png|webp)
获取元描述
curl -s https://example.com | grep -oP (?<=
与 OpenClaw 集成
使用 web_fetch 工具
javascript
// 在您的代理代码中
const content = await web_fetch({
url: https://example.com/article,
extractMode: markdown, // 或 text
maxChars: 10000
});
批量处理
对于多个 URL,按顺序处理并添加延迟:
URL1 → 获取 → 等待 2 秒 → URL2 → 获取 → 等待 2 秒 → URL3 → 获取
常见用例
1. 文章摘要
- 1. 获取文章内容
- 提取正文(移除导航、页脚、广告)
- 生成摘要
- 返回并注明来源
2. 产品信息
- 1. 获取产品页面
- 提取:名称、价格、描述、规格
- 格式化为结构化数据
- 返回便于对比的格式
3. 文档查询
- 1. 获取文档页面
- 提取相关章节
- 搜索特定主题
- 返回代码示例及说明
故障排除
| 问题 | 解决方案 |
|---|
| 内容为空/缺失 | 网站使用 JS 渲染 → 使用 BrowserAgent |
| 被网站屏蔽 |
添加 User-Agent、添加延迟、使用代理 |
| 超时 | 增加超时时间、检查 URL 有效性 |
| 乱码文本 | 检查字符集、尝试文本模式 |
| 需要登录 | 使用带会话 Cookie 的 BrowserAgent |
相关技能
- - BrowserAgent - 用于交互式/重度 JS 网站
- web_search - 用于在获取前查找 URL
- coding-agent - 用于处理提取的数据
安全注意事项
⚠️ 重要提示:
- - 遵守 robots.txt
- 不要抓取个人数据
- 尊重版权/服务条款
- 在请求之间添加延迟(2-5 秒)
- 不要使服务器过载
- 尽可能使用官方 API