data-scraper
Web Data Scraper — Extract structured data from web pages using curl + parsing. Lightweight, no browser required. Supports HTML-to-text, table extraction, price monitoring, and batch scraping.
When to Use
- - Extract text content from web pages (articles, blogs, docs)
- Scrape product prices, reviews, or listings
- Monitor pages for changes (price drops, new content)
- Batch-collect data from multiple URLs
- Convert HTML tables to structured formats (JSON/CSV)
Quick Start
CODEBLOCK0
Extraction Modes
Text Mode (default)
Fetches page and extracts readable content, stripping HTML tags, scripts, and styles. Similar to reader mode.
CODEBLOCK1
Selector Mode
Target specific CSS selectors for precise extraction.
CODEBLOCK2
Table Mode
Extract HTML tables into structured formats.
CODEBLOCK3
Link Mode
Extract all links from a page with optional filtering.
CODEBLOCK4
Batch Scraping
CODEBLOCK5
INLINECODE0 format:
CODEBLOCK6
Change Monitoring
CODEBLOCK7
Stores snapshots in data-scraper/snapshots/ with timestamps. Alerts via notification-hub when changes detected.
Output Formats
| Format | Flag | Use Case |
|---|
| Text | INLINECODE2 | Reading, summarization |
| JSON |
--format json | Data processing |
| CSV |
--format csv | Spreadsheets |
| Markdown |
--format md | Documentation |
Headers & Auth
CODEBLOCK8
Rate Limiting & Ethics
- - Default: 1 request per second per domain
- Respects
robots.txt when --polite flag is set - Configurable delay between requests
- Stops on 429 (Too Many Requests) and backs off
Error Handling
| Error | Behavior |
|---|
| 404 | Log and skip |
| 403/401 |
Warn about auth requirement |
| 429 | Exponential backoff (max 3 retries) |
| Timeout | Retry once with longer timeout |
| SSL error | Warn, option to proceed with
--insecure |
Integration
- - web-claude: Use as fallback when web_fetch isn't enough
- competitor-watch: Feed scraped data into competitor analysis
- seo-audit: Scrape competitor pages for SEO comparison
- performance-tracker: Collect social metrics from public profiles
data-scraper
Web数据抓取器 — 使用curl+解析技术从网页中提取结构化数据。轻量级,无需浏览器。支持HTML转文本、表格提取、价格监控和批量抓取。
适用场景
- - 从网页中提取文本内容(文章、博客、文档)
- 抓取产品价格、评论或列表
- 监控页面变化(价格下降、新内容)
- 从多个URL批量收集数据
- 将HTML表格转换为结构化格式(JSON/CSV)
快速开始
bash
从URL提取可读文本
data-scraper fetch https://example.com/article
提取特定元素
data-scraper extract https://example.com --selector h2, .price
监控变化
data-scraper watch https://example.com/product --interval 3600
提取模式
文本模式(默认)
获取页面并提取可读内容,去除HTML标签、脚本和样式。类似阅读器模式。
bash
data-scraper fetch URL
输出:干净的markdown文本
选择器模式
针对特定CSS选择器进行精确提取。
bash
data-scraper extract URL --selector .product-title, .price, .rating
输出:匹配元素作为结构化数据
表格模式
将HTML表格提取为结构化格式。
bash
data-scraper table URL --index 0
输出:行对象的JSON数组(表头→值映射)
链接模式
从页面提取所有链接,支持可选过滤。
bash
data-scraper links URL --filter *.pdf
输出:过滤后的绝对URL列表
批量抓取
bash
抓取多个URL
data-scraper batch urls.txt --output results/
带速率限制
data-scraper batch urls.txt --delay 2000 --output results/
urls.txt 格式:
https://site1.com/page
https://site2.com/page
https://site3.com/page
变化监控
bash
监控变化,差异时发出警报
data-scraper watch URL --selector .price --interval 3600
与之前的快照比较
data-scraper diff URL
快照存储在 data-scraper/snapshots/ 目录中,带有时间戳。检测到变化时通过notification-hub发出警报。
输出格式
| 格式 | 标志 | 用途 |
|---|
| 文本 | --format text | 阅读、摘要 |
| JSON |
--format json | 数据处理 |
| CSV | --format csv | 电子表格 |
| Markdown | --format md | 文档编写 |
请求头与认证
bash
自定义请求头
data-scraper fetch URL --header Authorization: Bearer TOKEN
基于Cookie的认证
data-scraper fetch URL --cookie session=abc123
覆盖User-Agent
data-scraper fetch URL --ua Mozilla/5.0...
速率限制与伦理
- - 默认:每个域名每秒1个请求
- 设置 --polite 标志时尊重 robots.txt
- 可配置请求间隔延迟
- 遇到429(请求过多)时停止并退避
错误处理
警告需要认证 |
| 429 | 指数退避(最多重试3次) |
| 超时 | 使用更长的超时时间重试一次 |
| SSL错误 | 发出警告,可选择使用 --insecure 继续 |
集成
- - web-claude:当web_fetch不足时作为备用方案
- competitor-watch:将抓取的数据输入竞争对手分析
- seo-audit:抓取竞争对手页面进行SEO对比
- performance-tracker:从公开资料收集社交指标