关于 Diffgrab
Diffgrab 是用于跟踪网页内容变化的工具,面向需要监控网页更新的开发者和研究者。它生成按章节分析的结构化差异,并保存 SQLite 快照历史;还集成 markgrab 与可选的 snapgrab 视觉差异。
主要功能
- 01检测网页内容变化
- 02生成统一差异和章节分析
- 03提供易读的变化摘要
- 04在 SQLite 中保存快照历史
- 05支持可选的截图视觉比较
适用场景
- 01监控网页是否发布新内容
- 02查看更新涉及的章节与行数
- 03回顾网页历史版本
- 04通过截图比较页面视觉变化
MCP 相关
Diffgrab 的 MCP 服务提供 5 种工具,用于注册 URL、检查变化、获取结构化差异、查看快照历史和停止跟踪。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
还没有获取到工具列表
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
diffgrab
通过结构化差异跟踪网页变化。集成 markgrab + snapgrab,原生支持 MCP。
from diffgrab import DiffTracker
tracker = DiffTracker()
await tracker.track("https://example.com")
changes = await tracker.check()
for c in changes:
if c.changed:
print(c.summary) # "3 lines added, 1 lines removed in sections: Introduction."
print(c.unified_diff) # Standard unified diff output
await tracker.close()
功能
- 变化检测 — 跟踪任意 URL,通过内容哈希检测内容变化
- 结构化差异 — 统一差异 + 章节级分析(哪些标题发生了变化)
- 易读摘要 — “章节 Intro、Methods 中新增 5 行,删除 2 行”
- 快照历史 — 使用 SQLite 存储,浏览任意网页的历史版本
- 由 markgrab 提供支持 — 通过 markgrab 提取 HTML/YouTube/PDF/DOCX 内容
- 视觉差异 — 可选通过 snapgrab 比较截图
- MCP 服务 — 为 Claude Code / MCP 客户端提供 5 种工具
- 附带 CLI —
diffgrab track、check、diff、history、untrack
工作原理
flowchart TD
A["diffgrab track URL"] --> B["Fetch initial snapshot\n(markgrab + snapgrab)"]
B --> C["Store baseline"]
C --> D["diffgrab check"]
D --> E["Fetch current page"]
E --> F{"Content\nhash match?"}
F -->|"changed"| G["Compute structured diff\n+ section analysis"]
F -->|"unchanged"| H["No changes"]
G --> I["📊 DiffResult\nadded / removed / modified"]
安装
pip install diffgrab
可选扩展:
pip install 'diffgrab[cli]' # CLI with click + rich
pip install 'diffgrab[visual]' # Visual diff with snapgrab
pip install 'diffgrab[mcp]' # MCP server with fastmcp
pip install 'diffgrab[all]' # Everything
使用方法
Python API
import asyncio
from diffgrab import DiffTracker
async def main():
tracker = DiffTracker()
# Track a URL (takes initial snapshot)
await tracker.track("https://example.com", interval_hours=12)
# Check for changes
changes = await tracker.check()
for change in changes:
if change.changed:
print(change.summary)
print(change.unified_diff)
# Get diff between specific snapshots
result = await tracker.diff("https://example.com", before_id=1, after_id=2)
# Browse snapshot history
history = await tracker.history("https://example.com", count=20)
# Stop tracking
await tracker.untrack("https://example.com")
await tracker.close()
asyncio.run(main())
便捷函数
from diffgrab import track, check, diff, history, untrack
await track("https://example.com")
changes = await check()
result = await diff("https://example.com")
snaps = await history("https://example.com")
await untrack("https://example.com")
CLI
# Track a URL
diffgrab track https://example.com --interval 12
# Check all tracked URLs for changes
diffgrab check
# Check a specific URL
diffgrab check https://example.com
# Show diff between snapshots
diffgrab diff https://example.com
diffgrab diff https://example.com --before 1 --after 3
# View snapshot history
diffgrab history https://example.com --count 20
# Stop tracking
diffgrab untrack https://example.com
MCP 服务
将以下内容添加到 Claude Code 的 MCP 配置中:
{
"mcpServers": {
"diffgrab": {
"command": "diffgrab-mcp",
"args": []
}
}
}
也可以使用 uvx:
{
"mcpServers": {
"diffgrab": {
"command": "uvx",
"args": ["--from", "diffgrab[mcp]", "diffgrab-mcp"]
}
}
}
MCP 工具:
| 工具 | 描述 |
|---|---|
track_url | 注册要跟踪变化的 URL |
check_changes | 检查已跟踪的 URL 是否发生变化 |
get_diff | 获取快照之间的结构化差异 |
get_history | 浏览快照历史 |
untrack_url | 停止跟踪 URL |
DiffResult
每次差异操作都会返回一个 DiffResult:
@dataclass
class DiffResult:
url: str # The tracked URL
changed: bool # Whether content changed
added_lines: int # Lines added
removed_lines: int # Lines removed
changed_sections: list[str] # Markdown headings with changes
unified_diff: str # Standard unified diff
summary: str # Human-readable summary
before_snapshot_id: int | None # DB ID of older snapshot
after_snapshot_id: int | None # DB ID of newer snapshot
before_timestamp: str # When older snapshot was taken
after_timestamp: str # When newer snapshot was taken
存储
快照存储在 SQLite 数据库 ~/.local/share/diffgrab/diffgrab.db 中(自动创建)。自定义路径:
tracker = DiffTracker(db_path="/path/to/custom.db")
QuartzUnit 生态系统
| 软件包 | 用途 | PyPI |
|---|---|---|
| markgrab | 将 HTML/YouTube/PDF/DOCX 转换为 Markdown | pip install markgrab |
| snapgrab | 将 URL 转换为截图 + 元数据 | pip install snapgrab |
| docpick | OCR + 大模型文档提取 | pip install docpick |
| feedkit | RSS 源收集 | pip install feedkit |
| diffgrab | 网页变化跟踪 | pip install diffgrab |
| browsegrab | 面向大模型的浏览器 Agent | 即将推出 |
使用项目
许可证
属于 QuartzUnit 生态系统 — 用于数据收集、提取、搜索和 AI Agent 安全防护的可组合 Python 库。
评论
支持 Markdown
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。