Files
paper-crawler/rss.py
2026-01-11 16:48:49 +08:00

22 lines
527 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import feedparser
# 示例 RSS 源
rss_url = "https://rss.cnki.net/knavi/rss/RJXB?pcode=CJFD,CCJD"
# 解析 RSS
feed = feedparser.parse(rss_url)
# 检查是否解析成功
if feed.bozo:
print("警告RSS 解析可能有问题")
# 输出 Feed 标题
print("Feed 标题:", feed.feed.get('title', '无标题'))
# 输出前5条条目
for entry in feed.entries:
print("标题:", entry.title)
print("链接:", entry.link)
print("发布时间:", entry.get('published', '无时间'))
print("-" * 40)