Uncommon RSS Elements

These elements are less common, but are useful for niche applications and may be present in any RSS feed.

An RSS feed can specify a small image which some aggregators display as a logo.

Accessing feed image

>>> import feedparser
>>> d = feedparser.parse('https://feedparser.readthedocs.io/en/latest/examples/rss20.xml')
>>> d.feed.image
{'title': 'Example banner',
'href': 'http://example.org/banner.png',
'width': 80,
'height': 15,
'link': 'http://example.org/'}

Feeds and entries can be assigned to multiple categories, and in some versions of RSS, categories can be associated with a “domain”. Both are free-form strings. For historical reasons, Universal Feed Parser makes multiple categories available as a list of tuples, rather than a list of dictionaries.

Accessing multiple categories

>>> import feedparser
>>> d = feedparser.parse('https://feedparser.readthedocs.io/en/latest/examples/rss20.xml')
>>> d.feed.categories
[('Syndic8', '1024'),
('dmoz', 'Top/Society/People/Personal_Homepages/P/')]

Each item in an RSS feed can have an “enclosure”, a delightful misnomer that is simply a link to an external file (usually a music or video file, but any type of file can be “enclosed”). Once rare, this element has recently gained popularity due to the rise of podcasting. Some clients (such as Apple’s iTunes) may automatically download enclosures; others (such as the web-based Bloglines) may simply render each enclosure as a link.

The RSS specification states that there can be at most one enclosure per item. However, Atom entries may contain more than one enclosure per entry, so Universal Feed Parser captures all of them and makes them available as a list.

Accessing enclosures

>>> import feedparser
>>> d = feedparser.parse('https://feedparser.readthedocs.io/en/latest/examples/rss20.xml')
>>> e = d.entries[0]
>>> len(e.enclosures)
1
>>> e.enclosures[0]
{'type': 'audio/mpeg',
'length': '1069871',
'href': 'http://example.org/audio/demo.mp3'}

Accessing feed cloud

No one is quite sure what a cloud is.

>>> import feedparser
>>> d = feedparser.parse('https://feedparser.readthedocs.io/en/latest/examples/rss20.xml')
>>> d.feed.cloud
{'domain': 'rpc.example.com',
'port': '80',
'path': '/RPC2',
'registerprocedure': 'pingMe',
'protocol': 'soap'}

Note

For more examples of accessing RSS elements, see the annotated examples: RSS 1.0, RSS 2.0, and RSS 2.0 with Namespaces.