rss-reader

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

RSS Reader Skill

RSS 阅读器技能

Read and parse RSS/Atom feeds.
读取并解析RSS/Atom订阅源。

When to Use

适用场景

  • Get latest articles from a feed
  • Subscribe to news sources
  • Monitor blog updates
  • Aggregate multiple feeds
  • 获取订阅源的最新文章
  • 订阅新闻来源
  • 监控博客更新
  • 聚合多个订阅源

Feed Information

订阅源信息

Get Feed Details

获取订阅源详情

bash
undefined
bash
undefined

Get feed info

获取订阅源信息

curl -s "https://example.com/feed.xml" | head -20
curl -s "https://example.com/feed.xml" | head -20

Check if RSS or Atom

检查是RSS还是Atom

curl -s "https://example.com/feed.xml" | head -1
undefined
curl -s "https://example.com/feed.xml" | head -1
undefined

Parse Feeds

解析订阅源

Using xmlstarlet

使用xmlstarlet

bash
undefined
bash
undefined

Install if needed

如有需要先安装

apt install xmlstarlet

apt install xmlstarlet

List all items

列出所有条目

curl -s "feed.xml" | xmlstarlet sel -t -m "//item" -v "title" -n
curl -s "feed.xml" | xmlstarlet sel -t -m "//item" -v "title" -n

Get latest 5 titles

获取最新5条标题

curl -s "feed.xml" | xmlstarlet sel -t -m "//item[position() <= 5]" -v "title" -n
undefined
curl -s "feed.xml" | xmlstarlet sel -t -m "//item[position() <= 5]" -v "title" -n
undefined

Using xmllint

使用xmllint

bash
undefined
bash
undefined

Parse with xmllint

使用xmllint解析

curl -s "feed.xml" | xmllint --format - 2>/dev/null | head -50
undefined
curl -s "feed.xml" | xmllint --format - 2>/dev/null | head -50
undefined

Using Python

使用Python

bash
undefined
bash
undefined

Simple feed parser

简单订阅源解析器

python3 -c " import xml.etree.ElementTree as ET import urllib.request
url = 'https://example.com/feed.xml' data = urllib.request.urlopen(url).read() root = ET# Find channel.fromstring(data)
for item in root.findall('.//item'): title = item.find('title') if title is not None: print(title.text) "
undefined
python3 -c " import xml.etree.ElementTree as ET import urllib.request
url = 'https://example.com/feed.xml' data = urllib.request.urlopen(url).read() root = ET# Find channel.fromstring(data)
for item in root.findall('.//item'): title = item.find('title') if title is not None: print(title.text) "
undefined

Using yq (if available)

使用yq(若已安装)

bash
undefined
bash
undefined

Convert RSS to YAML

将RSS转换为YAML

curl -s "feed.xml" | yq -x '.rss.channel.item[]'
undefined
curl -s "feed.xml" | yq -x '.rss.channel.item[]'
undefined

Common Commands

常用命令

List Feed Items

列出订阅源条目

bash
undefined
bash
undefined

Get all item titles

获取所有条目标题

curl -s "feed.xml" | grep -o '<title>[^<]*</title>' | sed 's/<title>//;s/</title>//'
curl -s "feed.xml" | grep -o '<title>[^<]*</title>' | sed 's/<title>//;s/</title>//'

With descriptions

包含描述内容

curl -s "feed.xml" | grep -o '<title>[^<]</title>|<description>[^<]</description>'
undefined
curl -s "feed.xml" | grep -o '<title>[^<]</title>|<description>[^<]</description>'
undefined

Get Latest N Items

获取最新N条条目

bash
undefined
bash
undefined

Latest 10 items with dates

包含日期的最新10条条目

curl -s "feed.xml" | grep -o '<item>.</item>' | head -10 |
while read item; do echo "$item" | grep -o '<title>[^<]
</title>' echo "$item" | grep -o '<pubDate>[^<]*</pubDate>' echo "---" done
undefined
curl -s "feed.xml" | grep -o '<item>.</item>' | head -10 |
while read item; do echo "$item" | grep -o '<title>[^<]
</title>' echo "$item" | grep -o '<pubDate>[^<]*</pubDate>' echo "---" done
undefined

Extract Links

提取链接

bash
undefined
bash
undefined

Get all article links

获取所有文章链接

curl -s "feed.xml" | grep -o '<link>[^<]*</link>' | sed 's/<link>//;s/</link>//'
undefined
curl -s "feed.xml" | grep -o '<link>[^<]*</link>' | sed 's/<link>//;s/</link>//'
undefined

Examples

示例

Hacker News RSS

Hacker News RSS

bash
curl -s "https://news.ycombinator.com/rss" | \
  grep -o '<title>[^<]*</title>' | sed 's/<title>//;s/<\/title>//' | head -20
bash
curl -s "https://news.ycombinator.com/rss" | \
  grep -o '<title>[^<]*</title>' | sed 's/<title>//;s/<\/title>//' | head -20

TechCrunch

TechCrunch

bash
curl -s "https://techcrunch.com/feed/" | \
  grep -o '<title>[^<]*</title>' | head -15
bash
curl -s "https://techcrunch.com/feed/" | \
  grep -o '<title>[^<]*</title>' | head -15

GitHub Trending

GitHub Trending

bash
undefined
bash
undefined

GitHub doesn't have RSS, but you can use GitHub's API

GitHub 没有原生RSS,但可以使用GitHub API

undefined
undefined

Feed URLs

订阅源URL格式

Common RSS feed patterns:
  • WordPress:
    /feed/
    or
    /feed/rss/
  • Medium:
    /{username}/feed
  • YouTube:
    https://www.youtube.com/feeds/videos.xml?channel_id={id}
  • Twitter: Use Nitter or RSSHub
常见RSS订阅源格式:
  • WordPress:
    /feed/
    /feed/rss/
  • Medium:
    /{username}/feed
  • YouTube:
    https://www.youtube.com/feeds/videos.xml?channel_id={id}
  • Twitter: 使用Nitter或RSSHub

Notes

注意事项

  • RSS feeds may have different element names (item vs entry)
  • Atom feeds use
    <entry>
    instead of
    <item>
  • Some feeds require user-agent headers
  • Consider caching feeds to avoid excessive requests
  • RSS订阅源的元素名称可能不同(item与entry)
  • Atom订阅源使用
    <entry>
    而非
    <item>
  • 部分订阅源需要user-agent请求头
  • 建议缓存订阅源以避免过度请求