Common Atom Elements ==================== Atom feeds generally contain more information than :abbr:`RSS (Rich Site Summary)` feeds (because more elements are required), but the most commonly used elements are still title, link, subtitle/description, various dates, and ID. This sample Atom feed is at `http://feedparser.org/docs/examples/atom10.xml `_. .. sourcecode:: xml Sample Feed For documentation <em>only</em> <p>Copyright 2005, Mark Pilgrim</p>< tag:feedparser.org,2005-11-09:/docs/examples/atom10.xml Sample Toolkit 2005-11-09T11:56:34Z First entry title tag:feedparser.org,2005-11-09:/docs/examples/atom10.xml:3 2005-11-09T00:23:47Z 2005-11-09T11:56:34Z Watch out for nasty tricks
Watch out for nasty tricks
The feed elements are available in ``d.feed``. Accessing Common Feed Elements ------------------------------ :: >>> import feedparser >>> d = feedparser.parse('http://feedparser.org/docs/examples/atom10.xml') >>> d.feed.title u'Sample feed' >>> d.feed.link u'http://example.org/' >>> d.feed.subtitle u'For documentation only' >>> d.feed.updated u'2005-11-09T11:56:34Z' >>> d.feed.updated_parsed (2005, 11, 9, 11, 56, 34, 2, 313, 0) >>> d.feed.id u'tag:feedparser.org,2005-11-09:/docs/examples/atom10.xml' Entries are available in ``d.entries``, which is a list. You access entries in the order in which they appear in the original feed, so the first entry is ``d.entries[0]``. Accessing Common Entry Elements ------------------------------- :: >>> import feedparser >>> d = feedparser.parse('http://feedparser.org/docs/examples/atom10.xml') >>> d.entries[0].title u'First entry title' >>> d.entries[0].link u'http://example.org/entry/3 >>> d.entries[0].id u'tag:feedparser.org,2005-11-09:/docs/examples/atom10.xml:3' >>> d.entries[0].published u'2005-11-09T00:23:47Z' >>> d.entries[0].published_parsed (2005, 11, 9, 0, 23, 47, 2, 313, 0) >>> d.entries[0].updated u'2005-11-09T11:56:34Z' >>> d.entries[0].updated_parsed (2005, 11, 9, 11, 56, 34, 2, 313, 0) >>> d.entries[0].summary u'Watch out for nasty tricks' >>> d.entries[0].content [{'type': u'application/xhtml+xml', 'base': u'http://example.org/entry/3', 'language': u'en-US', 'value': u'
Watch out for nasty tricks
'}] .. note:: The parsed summary and content are not the same as they appear in the original feed. The original elements contained dangerous :abbr:`HTML (HyperText Markup Language)` markup which was sanitized. See :ref:`advanced.sanitization` for details. Because Atom entries can have more than one content element, ``d.entries[0].content`` is a list of dictionaries. Each dictionary contains metadata about a single content element. The two most important values in the dictionary are the content type, in ``d.entries[0].content[0].type``, and the actual content value, in ``d.entries[0].content[0].value``. You can get this level of detail on other Atom elements too.