Uncommon RSS Elements [Universal Feed Parser]
Keywords: RSS, Atom, CDF, XML, feed, parser, Python

# Universal Feed Parser

Parse RSS and Atom feeds in Python. 2000 unit tests. Open source.

- Download ·
- Documentation ·
- Unit tests ·
- Report a bug

## 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.

### Example: Accessing feed image

    >>> import feedparser
    >>> d = feedparser.parse('http://feedparser.org/docs/examples/rss20.xml')
    >>> d.feed.image
    {'title': u'Example banner',
     'url': u'http://example.org/banner.png',
     'width': 80,
     'height': 15,
     'link': u'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.

### Example: Accessing multiple categories

    >>> import feedparser
    >>> d = feedparser.parse('http://feedparser.org/docs/examples/rss20.xml')
    >>> d.feed.categories
    [(u'Syndic8', u'1024'),
     (u'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. Some aggregators automatically download enclosures (although this technique has known problems). Some aggregators render each enclosure as a link. Most aggregators ignore them.

The RSS specification states that there can be at most one enclosure per item. However, because some feeds break this rule, Universal Feed Parser captures all of them and makes them available as a list.

### Example: Accessing enclosures

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

No one is quite sure what a cloud is.

### Example: Accessing feed cloud

    >>> import feedparser
    >>> d = feedparser.parse('http://feedparser.org/docs/examples/rss20.xml')
    >>> d.feed.cloud
    {'domain': u'rpc.example.com',
     'port': u'80',
     'path': u'/RPC2',
     'registerprocedure': u'pingMe',
     'protocol': u'soap'}

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

← Getting Detailed Information on Atom Elements
Uncommon Atom Elements →