用途:当用户提到 RSS、feed、RSS reader 或需要从 RSS 来源获取新闻时,使用该技能抓取并解析订阅源内容。
主要能力:通过 curl 获取原始 RSS/Atom 数据,用 xmllint 按 XPath 提取条目。可提取标题、链接、日期等字段,支持 RSS 的 item 与 Atom 的 entry 两种格式,并可将结果保存到文件。资料还列出了常用源与 hnrss.org 参数。
使用方式:抓取原始源:curl -s "https://hnrss.org/frontpage" | head -100。用 xmllint 提取标题: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。Atom 源使用 //entry/title/text(),例如 curl -s "https://github.com/blog.atom" | xmllint --xpath '//entry/title/text()' - 2>/dev/null。保存到文件:curl -s "https://hnrss.org/frontpage" -o /tmp/hn-feed.xml,再用 xmllint 读取。hnrss.org 支持 count=N、points=N、comments=N、q=keyword 等参数。
适用场景:读取新闻或博客更新、批量抓取多个源、按关键词或热度筛选 Hacker News 条目。
限制:部分源可能较慢或限流;应遵守 robots.txt,避免高频请求;建议缓存结果。RSS 与 Atom 元素不同,需先判断格式再解析。