timmy revised this gist 10 months ago. Go to revision
No changes
timmy revised this gist 11 months ago. Go to revision
No changes
timmy revised this gist 11 months ago. Go to revision
1 file changed, 18 insertions
rss_feed_parser.py(file created)
| @@ -0,0 +1,18 @@ | |||
| 1 | + | import feedparser | |
| 2 | + | ||
| 3 | + | # RSS Feed 的 URL | |
| 4 | + | rss_url = "https://www.twcert.org.tw/tw/rss-104-1.xml" | |
| 5 | + | ||
| 6 | + | # 解析 RSS Feed | |
| 7 | + | feed = feedparser.parse(rss_url) | |
| 8 | + | ||
| 9 | + | # 顯示 Feed 的標題 | |
| 10 | + | print(f"Feed Title: {feed.feed.title}\n") | |
| 11 | + | ||
| 12 | + | # 遍歷每一個項目 | |
| 13 | + | for entry in feed.entries: | |
| 14 | + | print(f"標題: {entry.title}") | |
| 15 | + | print(f"連結: {entry.link}") | |
| 16 | + | print(f"發布日期: {entry.published}") | |
| 17 | + | # print(f"描述: {entry.description}\n") | |
| 18 | + | ||
Newer
Older