Web Monitor
Track web pages for changes. Stores snapshots, computes diffs, supports CSS selectors.
Quick Start
CODEBLOCK0
Commands
| Command | Args | Description |
|---|
| INLINECODE0 | INLINECODE1 | Add URL to watch, take initial snapshot |
| INLINECODE2 |
<url-or-name> | Stop watching a URL |
|
list |
[-f json] | List all watched URLs with stats |
|
check |
[url-or-name] [-f json] | Check for changes (all or one) |
|
diff |
<url-or-name> | Show last recorded diff |
|
snapshot |
<url-or-name> [-l lines] | Show current snapshot |
Output Symbols
- - 🔔 CHANGED — page content changed (shows diff preview)
- ✅ No changes
- 📸 Initial snapshot taken
- ❌ Error fetching
Data
Stored in ~/.web-monitor/ (override with WEB_MONITOR_DIR env var):
- -
watches.json — watch list config - INLINECODE15 — stored page content + diffs
Tips
- - Use
--selector to monitor specific elements (prices, article lists, etc.) - Use
--format json for programmatic checking (heartbeat integration) - CSS selectors require beautifulsoup4 (included via
--with flag) - Text is normalized to reduce noise from timestamps, whitespace, ads
Web Monitor
追踪网页变化。存储快照,计算差异,支持CSS选择器。
快速开始
bash
添加要监控的URL
uv run --with beautifulsoup4 python scripts/monitor.py add https://example.com --name Example
使用CSS选择器添加(监控特定区域)
uv run --with beautifulsoup4 python scripts/monitor.py add https://example.com/pricing -n Pricing -s .pricing-table
检查所有已监控URL的变化
uv run --with beautifulsoup4 python scripts/monitor.py check
检查特定URL
uv run --with beautifulsoup4 python scripts/monitor.py check Example
列出已监控的URL
uv run --with beautifulsoup4 python scripts/monitor.py list
查看上次差异
uv run --with beautifulsoup4 python scripts/monitor.py diff Example
查看当前快照
uv run --with beautifulsoup4 python scripts/monitor.py snapshot Example --lines 50
移除
uv run --with beautifulsoup4 python scripts/monitor.py remove Example
命令
| 命令 | 参数 | 描述 |
|---|
| add | <url> [-n name] [-s selector] | 添加要监控的URL,获取初始快照 |
| remove |
| 停止监控某个URL |
| list | [-f json] | 列出所有已监控的URL及统计信息 |
| check | [url-or-name] [-f json] | 检查变化(全部或单个) |
| diff | | 显示上次记录的差异 |
| snapshot | [-l lines] | 显示当前快照 |
输出符号
- - 🔔 已变更 — 页面内容发生变化(显示差异预览)
- ✅ 无变化
- 📸 已获取初始快照
- ❌ 获取失败
数据
存储在 ~/.web-monitor/(可通过 WEBMONITORDIR 环境变量覆盖):
- - watches.json — 监控列表配置
- snapshots/ — 存储的页面内容及差异
提示
- - 使用 --selector 监控特定元素(价格、文章列表等)
- 使用 --format json 进行程序化检查(心跳集成)
- CSS选择器需要beautifulsoup4(通过 --with 标志包含)
- 文本经过规范化处理以减少时间戳、空白和广告带来的干扰