mcpField
R
rss-fetch

rss-fetch

github.com/okou-ai生产力8179 次安装1 周前更新
代码仓库

关于 rss-fetch

rss-fetch 是一份通过命令行获取和解析 RSS、Atom 源的操作指南,面向需要提取标题、链接、日期或批量查看订阅内容的用户。

主要功能

  1. 01使用 curl 获取订阅源
  2. 02用 xmllint 和 XPath 解析 XML
  3. 03提取条目标题、链接与日期
  4. 04查询 Hacker News RSS 参数
  5. 05循环处理多个订阅源

适用场景

  1. 01查看 Hacker News 热门条目
  2. 02按关键词或分数筛选 HN 源
  3. 03提取订阅条目信息用于脚本
  4. 04保存源文件并解析其内容

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/okou-ai/okou-skills --skill rss-fetch

安装后在 Claude Code 中输入/rss-fetch确认已加载。

详细介绍

使用方法

1. 获取原始 RSS Feed
curl -s "https://hnrss.org/frontpage" | head -100
2. 使用 xmllint 解析 RSS

从 RSS feed 中提取标题:

curl -s "https://hnrss.org/frontpage" | xmllint --xpath '//item/title/text()' - 2>/dev/null

提取标题和链接:

curl -s "https://hnrss.org/frontpage" | xmllint --format - | grep -E '<title>|<link>' | head -20
3. 获取详细条目
curl -s "https://hnrss.org/frontpage" | xmllint --xpath '//item' - 2>/dev/null | xmllint --format - | head -50
4. 解析 Atom Feed

Atom feed 使用 <entry> 而非 <item>:

curl -s "https://github.com/blog.atom" | xmllint --xpath '//entry/title/text()' - 2>/dev/null

常用 RSS Feed

来源URL
Hacker Newshttps://hnrss.org/frontpage
HN Besthttps://hnrss.org/best
TechCrunchhttps://techcrunch.com/feed/
Ars Technicahttps://feeds.arstechnica.com/arstechnica/index
The Vergehttps://www.theverge.com/rss/index.xml
Reddit(任意子版块)https://www.reddit.com/r/programming/.rss
GitHub Bloghttps://github.blog/feed/

示例

获取 Hacker News 头条
curl -s "https://hnrss.org/frontpage?count=10" | xmllint --xpath '//item/title/text()' - 2>/dev/null | tr '\n' '\n'
获取故事链接
curl -s "https://hnrss.org/frontpage?count=5" | grep -oP '<link>\K[^<]+' | grep -v hnrss
获取多个 Feed
FEEDS=(
  "https://hnrss.org/frontpage?count=5"
  "https://techcrunch.com/feed/"
)

for feed in "${FEEDS[@]}"; do
  echo "=== $feed ==="
  curl -s "$feed" | xmllint --xpath '//item/title/text()' - 2>/dev/null | head -5
  echo ""
done
提取标题、链接和日期
curl -s "https://hnrss.org/frontpage?count=3" | xmllint --format - | awk '
  /<item>/ { in_item=1 }
  /<\/item>/ { in_item=0; print "---" }
  in_item && /<title>/ { gsub(/<[^>]*>/, ""); print "Title: " $0 }
  in_item && /<link>/ { gsub(/<[^>]*>/, ""); print "Link: " $0 }
  in_item && /<pubDate>/ { gsub(/<[^>]*>/, ""); print "Date: " $0 }
  '
将 Feed 保存到文件
curl -s "https://hnrss.org/frontpage" -o /tmp/hn-feed.xml
xmllint --xpath '//item/title/text()' /tmp/hn-feed.xml

HN RSS 选项

Hacker News RSS(hnrss.org)支持以下参数:

参数说明
count=N条目数量(默认值为 20)
points=N最低分数
comments=N最低评论数
q=keyword搜索关键词
# Top stories with 100+ points
curl -s "https://hnrss.org/frontpage?points=100&count=10"

# Search for "AI" topics
curl -s "https://hnrss.org/frontpage?q=AI&count=10"

RSS 与 Atom 格式对比

元素RSSAtom
容器<item><entry>
标题<title><title>
链接<link><link href="...">
摘要<description><summary>
日期<pubDate><published>

指南

  1. 检查 Feed 格式:先使用 head 查看它是 RSS 还是 Atom
  2. 使用 xmllint:最适合在 XML 上执行 XPath 查询的工具
  3. 处理错误:有些 Feed 可能响应缓慢或受到速率限制
  4. 遵守 robots.txt:不要频繁向 Feed 发送请求
  5. 缓存结果:Feed 不会每秒更新

评论

支持 Markdown