RSS Fetcher - 统一RSS采集系统
核心特性
增量抓取 - 只抓取新文章,基于URL哈希自动去重
自动标签 - 优先使用RSS自带category,无则自动提取标题关键词
HTML报告 - 生成可筛选的静态HTML页面,支持日期/分类/标签多维度筛选
源健康监控 - 检测RSS源可用性,支持批量检查
分类管理 - 文章自动继承源的分类,支持多维度筛选
超时设置 - 单源30秒超时,避免长时间阻塞
数据库设计
表结构
表名 | 用途 |
---|---|
articles | 文章主数据 |
tags | 标签定义 |
article_tags | 文章-标签关联 |
fetch_logs | 抓取日志 |
说明:RSS源通过 config/sources.json 文件管理,不存入数据库
关键设计
时间戳使用 INTEGER (Unix时间戳) - 查询更快、比较更简单
published_at NOT NULL - 必填,缺失时标记为 UNRELIABLE_TIME (1970-01-01)
URL唯一索引 - 确保去重
多标签支持 - 一篇文章可拥有多个标签
category字段 - 继承自sources.json的分类配置
快速开始
cd skills/rss_fetcher
python3 scripts/init_db.py
编辑 config/sources.json,添加你的RSS源:
{
"sources": [
{
"id": "openai",
"name": "OpenAI Blog",
"url": "https://openai.com/blog/rss.xml",
"category": "tech",
"enabled": true
}
]
}
# 抓取所有源(最近24小时)/ Fetch all sources (last 24 hours)
python3 scripts/fetch.py
# 抓取指定源 / Fetch specific sources
python3 scripts/fetch.py --sources openai huggingface
# 抓取最近48小时 / Fetch last 48 hours
python3 scripts/fetch.py --hours 48
# 使用更多线程(默认20,最大50)/ Use more workers (default 20, max 50)
python3 scripts/fetch.py --workers 50
抓取后记得更新HTML报告 - 新抓取的文章需要重新生成页面才能在浏览器中查看
python3 scripts/fetch.py && python3 scripts/generate_html.py
注意:每次抓取新文章后,必须重新生成HTML页面才能看到最新内容。
# 抓取并立即更新HTML(推荐工作流)/ Fetch and update HTML (recommended workflow)
python3 scripts/fetch.py && python3 scripts/generate_html.py
# 单独生成HTML(已有新数据时)/ Generate HTML only (when new data exists)
python3 scripts/generate_html.py
# 打开查看 / Open to view
open data/index.html
# 或浏览器访问 / Or browser: file:///.../rss_fetcher/data/index.html
HTML报告功能
日期筛选 - 起止日期选择 |
分类筛选 - 按文章分类筛选 |
关键词搜索 - 实时搜索标题 |
标签多选 - 多标签组合筛选(AND逻辑)|
实时统计 - 显示筛选结果数量 |
# 检查所有源的健康状态 / Check all source health
python3 scripts/source.py check
# 查看源统计 / View source statistics
python3 scripts/source.py stats
# 添加新源 / Add new source
python3 scripts/source.py add myblog "My Blog" "https://example.com/feed.xml" tech
# 禁用/启用/删除源 / Disable/enable/remove source
python3 scripts/source.py disable myblog
python3 scripts/source.py enable myblog
python3 scripts/source.py remove myblog
# 终端表格查看最近文章 / View recent articles in terminal table
python3 scripts/list.py
# 查看最近48小时 / View last 48 hours
python3 scripts/list.py --hours 48
# 按分类查看 / View by category
python3 scripts/list.py --category tech
# JSON格式输出 / JSON output
python3 scripts/list.py --json
配置文件
sources.json
{
"_description": "RSS源配置文件 | RSS source config file",
"_updated": "2026-03-15",
"_total_sources": 111,
"sources": [
{
"id": "openai",
"name": "OpenAI Blog",
"url": "https://openai.com/blog/rss.xml",
"category": "tech",
"enabled": true
}
]
}
字段说明:
id - 源唯一标识 |
name - 显示名称 |
url - RSS订阅地址 |
category - 文章分类 |
enabled - 是否启用 |
分类可自由定义,在 sources.json 中使用任意分类名称即可。
自动标签系统
标签生成逻辑
优先使用RSS自带category - 提取 标签内容
Fallback