RSS and Atom

news/2025/11/15 20:49:38/文章来源:https://www.cnblogs.com/zhangzhihui/p/19226227
What is RSS?
 
ChatGPT said:

RSS (Really Simple Syndication) is a standard web format used to publish frequently updated content, such as news articles, blog posts, podcasts, and announcements.

An RSS feed is essentially a machine-readable list of updates, written in XML, that apps and websites can subscribe to.


✅ What RSS Is Used For

RSS allows users (or applications) to:

  • Subscribe to websites

  • Receive automatic updates whenever new content is published

  • Aggregate many sites into one place (news readers)

For example, instead of visiting 20 news websites, you subscribe to their RSS feeds, and a reader app shows you all updates in one list.


🧠 How RSS Works (Simple)

  1. A website publishes an RSS feed (an XML file) at a URL, e.g.:

    https://example.com/feed.xml
  2. Your RSS reader app checks this file regularly.

  3. When the website updates it (new article → new <item>), your reader shows a notification.


📄 RSS Feed Example (Very Simple XML)

<rss version="2.0"><channel><title>Python News</title><link>https://python.org/</link><description>Latest Python updates</description><item><title>Python 3.13 Released</title><link>https://python.org/downloads/release/3.13/</link><pubDate>Mon, 20 Oct 2025 12:00:00 GMT</pubDate></item></channel>
</rss>

An RSS reader would show:

  • Python 3.13 Released

And clicking it takes you to the link.


⭐ Why RSS Is Useful

  • You don’t need to check websites manually.

  • You get updates instantly.

  • No algorithms decide what you see — you control your feed.

  • Many news apps, podcast apps, and blogs rely on RSS.


📥 Examples of RSS Readers

  • Feedly

  • Inoreader

  • NetNewsWire

  • Thunderbird

  • Reeder (iOS / macOS)


🔌 Why Programmers Use RSS

RSS feeds are easy to process with code.

For example, Python can parse an RSS feed:

import feedparser
feed = feedparser.parse("https://example.com/rss")
for item in feed.entries:print(item.title)

If you want, I can also explain:

  • The difference between RSS and Atom feeds

  • How to parse RSS with Python

  • How to create your own RSS feed

Would you like that?

 
You said:
Yes, I would.
 
ChatGPT said:

Great — here’s a clear explanation of RSS vs Atom, plus how to parse RSS in Python, and how to create your own RSS feed.


🆚 1. RSS vs Atom: What’s the Difference?

RSS and Atom are both XML formats for publishing web feeds, but they have some differences.

✔ RSS (Really Simple Syndication)

  • Older (1999)

  • Simpler format

  • More widespread historically

  • Version widely used: RSS 2.0

  • Uses <item> for entries

✔ Atom (IETF Standard, 2005)

  • Newer, more standardized

  • More flexible and consistent

  • Uses <entry> instead of <item>

  • Contains built-in elements for:

    • Author

    • ID

    • Updated time

    • Links with relation types

Quick Comparison

FeatureRSSAtom
Standard? No single standard Yes (IETF RFC 4287)
Flexibility Less More
Common? Very common Common
Date format Often inconsistent ISO 8601 standardized
Entry label <item> <entry>

Both formats are still used today.

For most purposes, RSS is enough and easier.


🧪 2. How to Parse RSS Feeds in Python

The easiest library is feedparser.

Install:

pip install feedparser

Example: Read an RSS feed

import feedparserurl = "https://hnrss.org/frontpage"  # Hacker News RSS
feed = feedparser.parse(url)print("Feed title:", feed.feed.title)for entry in feed.entries[:5]:print(entry.title)print(entry.link)print("---")

What you get:

Feed title: Hacker News: Front Page
Activeloop (YC S18) Is Hiring MTS(Back End)and AI Search Engineer
https://careers.activeloop.ai/
---
Our investigation into the suspicious pressure on Archive.today
https://adguard-dns.io/en/blog/archive-today-adguard-dns-block-demand.html
---
One Handed Keyboard
https://github.com/htx-studio/One-Handed-Keyboard
---
NATO Ended Russia's Estonian Air Incursions
https://themilitaryanalyst.com/2025/11/13/the-real-story-how-nato-ended-russias-estonian-air-incursions/
---
Spec-Driven Development: The Waterfall Strikes Back
https://marmelab.com/blog/2025/11/12/spec-driven-development-waterfall-strikes-back.html
---

Feedparser works for RSS and Atom automatically.


🧱 3. How to Create Your Own RSS Feed (Simple Example)

A minimal RSS 2.0 feed:

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"><channel><title>Frank's Blog</title><link>https://example.com</link><description>Updates from Frank</description><item><title>Hello World</title><link>https://example.com/hello</link><guid>1</guid><pubDate>Sun, 16 Nov 2025 12:00:00 GMT</pubDate><description>This is my first article.</description></item></channel>
</rss>

Save it as feed.xml and serve it via your website.


🧱 4. Create an RSS Feed Using Python

Here’s a simple script to generate RSS XML:

 
from datetime import datetime
import xml.etree.ElementTree as ETrss = ET.Element("rss", version="2.0")
channel = ET.SubElement(rss, "channel")ET.SubElement(channel, "title").text = "Frank's Blog"
ET.SubElement(channel, "link").text = "https://example.com"
ET.SubElement(channel, "description").text = "Updates from Frank"item = ET.SubElement(channel, "item")
ET.SubElement(item, "title").text = "Hello World"
ET.SubElement(item, "link").text = "https://example.com/hello"
ET.SubElement(item, "guid").text = "1"pub_date = datetime.utcnow().strftime("%a, %d %b %Y %H:%M:%S GMT")
ET.SubElement(item, "pubDate").text = pub_date
ET.SubElement(item, "description").text = "This is my first article."tree = ET.ElementTree(rss)
tree.write("feed.xml", encoding="utf-8", xml_declaration=True)

Output: a valid RSS feed file feed.xml.


🧩 Want More?

I can also show you:

  • How to create Atom feeds

 


✅ How to Create an Atom Feed

Atom is a more modern, standardized format than RSS.
Here is a minimal valid Atom 1.0 feed.


📄 Example Atom Feed (XML)

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Frank's Atom Feed</title><link href="https://example.com/"/><updated>2025-11-16T12:00:00Z</updated><id>https://example.com/feed.atom</id><entry><title>Hello World</title><link href="https://example.com/hello"/><id>tag:example.com,2025-11-16:/hello</id><updated>2025-11-16T12:00:00Z</updated><summary>This is my first Atom entry.</summary></entry></feed>

Atom uses:

  • <feed> instead of <rss>

  • <entry> instead of <item>

  • <updated> in ISO 8601 format

  • <id> a globally unique identifier


🧱 Generate an Atom Feed with Python

from datetime import datetime
import xml.etree.ElementTree as ETATOM_NS = "http://www.w3.org/2005/Atom"
ET.register_namespace("", ATOM_NS)feed = ET.Element("{%s}feed" % ATOM_NS)ET.SubElement(feed, "{%s}title" % ATOM_NS).text = "Frank's Atom Feed"
ET.SubElement(feed, "{%s}link" % ATOM_NS, href="https://example.com/")
ET.SubElement(feed, "{%s}updated" % ATOM_NS).text = datetime.utcnow().isoformat() + "Z"
ET.SubElement(feed, "{%s}id" % ATOM_NS).text = "https://example.com/feed.atom"entry = ET.SubElement(feed, "{%s}entry" % ATOM_NS)
ET.SubElement(entry, "{%s}title" % ATOM_NS).text = "Hello World"
ET.SubElement(entry, "{%s}link" % ATOM_NS, href="https://example.com/hello")
ET.SubElement(entry, "{%s}id" % ATOM_NS).text = "tag:example.com,2025-11-16:/hello"
ET.SubElement(entry, "{%s}updated" % ATOM_NS).text = datetime.utcnow().isoformat() + "Z"
ET.SubElement(entry, "{%s}summary" % ATOM_NS).text = "This is my first Atom entry."tree = ET.ElementTree(feed)
tree.write("feed.atom", encoding="utf-8", xml_declaration=True)

This creates a file feed.atom.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/966495.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Wi-Fi FTM(Fine Timing Measurement)简介

1. 什么是 Wi-Fi FTM? Wi-Fi FTM(Fine Timing Measurement)是 IEEE 802.11mc 标准中引入的一项精确测距技术。它通过 Wi-Fi 设备之间的多次往返时间(Round-Trip Time, RTT)测量,计算两者之间的距离,从而实现室内…

通用会话控制方案

一、会话控制概念目的:在无状态的 HTTP 请求间识别/鉴权用户身份并维持登录状态。 核心问题:谁保存“用户状态”?(服务器 / 客户端 / 第三方认证服务器),以及如何安全地在多请求间传递该凭证(Cookie / Authoriz…

LISTAGG 用于将多行数据聚合为单行字符串(拼接),而与其功能相反的需求是 将单行字符串按指定分隔符拆分为多行数据

LISTAGG 用于将多行数据聚合为单行字符串(拼接),而与其功能相反的需求是 将单行字符串按指定分隔符拆分为多行数据。Oracle 中没有直接对应的内置内置函数**,但可以通过以下方法实现类似效果: 方法1:使用 CONNEC…

ESP32 I2S音频总线学习笔记(八):添加按键控制功能 - 详解

ESP32 I2S音频总线学习笔记(八):添加按键控制功能 - 详解pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Conso…

2025年8款AI论文写作神器推荐:轻松搞定毕业论文查重

2025 年毕业论文仍是学子难题,导师强调其重要性让同学们压力倍增。从选题到应对查重,每一步都困难重重。不过,科技发展带来新希望,AI 技术可提高写作效率。文章推荐了 2025 年 8 款 AI 论文写作神器,如 PaperNex、…

基于python的酒店管理系统_36rhk752(Pycharm Flask Django成品源码LW) - 详解

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

pythontip 从字典中删除一组键

编写一个程序,使用提供的键列表从字典中删除指定的键集合。 定义函数remove_keys(),有两个参数:字典dict_input和键列表key_list。 在函数中,从字典中删除key_list中存在的所有键。 返回更新后的字典。 示例输入 {…

Softmax 函数全面而详细的解读,原理、图像、应用 - 详解

Softmax 函数全面而详细的解读,原理、图像、应用 - 详解2025-11-15 20:18 tlnshuju 阅读(0) 评论(0) 收藏 举报pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important;…

中级前端工程师详细技能清单

一、JavaScript:超越语法,深入核心技能领域具体技能点中级要求与深度理解语言核心 作用域与闭包 能解释清楚词法作用域,能使用闭包解决实际问题(如模块模式、数据私有化),能避免常见的内存泄漏问题。 原型与原型…

Atcoder FPS 24 记录

awa A 记 \(f_{i,j}\) 表示前 \(i\) 天花了 \(j\) 块的方案,有转移 \(f_{i,j}=f_{i-1,j-1}+f_{i-1,j-3}+f_{i-1,j-4}+f_{i-1,j-6}\),边界是 \(f_{0,0}=1\)。 把 \(f_i\) 的生成函数写出来,也就是 \(F_i(x)=\sum\lim…

扩展单调栈扫描线维护历史信息

扩展单调栈&扫描线维护历史信息同样来自模拟赛 T4。引入 考虑如下问题: 给定一个初始为空的数列 \(a\),有 \(c\) 次操作,每次操作形如:\(1\) \(x\):将值 \(x\) 放入 \(a\) 的末尾。(保证这个操作有 \(n\) 次…

酵母单杂交 (Y1H):蛋白质 - DNA 互作研究的 基因解码器

酵母单杂交 (Y1H) 是一种研究蛋白质与 DNA 相互作用的经典分子生物学技术,基于转录因子的结构特性,通过报告基因表达检测实现蛋白质 - DNA 互作的高通量分析,广泛应用于基因调控网络解析和转录因子鉴定。 一、核心原…

ORACLE行记录转字符串用分隔符连接的两个函数:WM_CONCAT、LISTAGG

WM_CONCAT 是 Oracle 数据库中一个非官方的聚合函数(属于 Oracle 内部函数,未正式文档正式支持),用于将多行数据的某一列值拼接成一个字符串,通常用逗号分隔。 基本语法 WM_CONCAT(列名)作用:将分组内指定列的多…

MySQL 8+ 日志管理与数据备份恢复实战指南 - 指南

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

航运、应急、工业适用,AORO P1100三防平板引领行业数字化变革 - 详解

航运、应急、工业适用,AORO P1100三防平板引领行业数字化变革 - 详解pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: &q…

20232419 2025-2026-1 《网络与系统攻防技术》实验五实验报告

1实验内容 1)从www.besti.edu.cn、baidu.com、sina.com.cn中选择一个DNS域名进行查询,获取如下信息: DNS注册人及联系方式 该域名对应IP地址 IP地址注册人及联系方式 IP地址所在国家、城市和具体地理位置 PS:使用w…

为什么高手写 CSS 都偏爱 rem?这三大优势无法拒绝

核心概念:rem 是什么?rem 的全称是 root em。em 是相对于其父元素的字体大小。rem 是相对于根元素(<html>)的字体大小。、默认情况下,几乎所有浏览器的根元素字体大小都是 16px。所以,在未做任何修改时:1…

完整教程:FPGA 49 ,Xilinx Vivado 软件术语解析(Vivado 界面常用英文字段详解,以及实际应用场景和注意事项 )

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

前端css中rem的作用

核心概念:rem 是什么?rem 的全称是 root em。em 是相对于其父元素的字体大小。rem 是相对于根元素(<html>)的字体大小。、默认情况下,几乎所有浏览器的根元素字体大小都是 16px。所以,在未做任何修改时:1…

第三十天

今天的学习重心放在了Java Web开发的核心实践上,围绕石家庄铁道大学选课管理系统的功能迭代展开,收获比预期更扎实。 上午先梳理了项目的分层架构逻辑,重点巩固了Controller、Service、Dao三层的职责划分——Contro…