<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Common RSS Elements — feedparser 5.1.3 documentation</title> <link rel="stylesheet" href="_static/default.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <link rel="stylesheet" href="_static/feedparser.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '', VERSION: '5.1.3', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <link rel="top" title="feedparser 5.1.3 documentation" href="index.html" /> <link rel="up" title="Basic Features" href="basic.html" /> <link rel="next" title="Common Atom Elements" href="common-atom-elements.html" /> <link rel="prev" title="Introduction" href="introduction.html" /> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="common-atom-elements.html" title="Common Atom Elements" accesskey="N">next</a> |</li> <li class="right" > <a href="introduction.html" title="Introduction" accesskey="P">previous</a> |</li> <li><a href="index.html">feedparser 5.1.3 documentation</a> »</li> <li><a href="basic.html" accesskey="U">Basic Features</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="common-rss-elements"> <h1>Common <abbr title="Rich Site Summary">RSS</abbr> Elements<a class="headerlink" href="#common-rss-elements" title="Permalink to this headline">¶</a></h1> <p>The most commonly used elements in <abbr title="Rich Site Summary">RSS</abbr> feeds (regardless of version) are title, link, description, publication date, and entry ID. The publication date comes from the pubDate element, and the entry ID comes from the guid element.</p> <p>This sample <abbr title="Rich Site Summary">RSS</abbr> feed is at <a class="reference external" href="http://feedparser.org/docs/examples/rss20.xml">http://feedparser.org/docs/examples/rss20.xml</a>.</p> <div class="highlight-xml"><div class="highlight"><pre><span class="cp"><?xml version="1.0" encoding="utf-8"?></span> <span class="nt"><rss</span> <span class="na">version=</span><span class="s">"2.0"</span><span class="nt">></span> <span class="nt"><channel></span> <span class="nt"><title></span>Sample Feed<span class="nt"></title></span> <span class="nt"><description></span>For documentation <span class="ni">&lt;</span>em<span class="ni">&gt;</span>only<span class="ni">&lt;</span>/em<span class="ni">&gt;</span><span class="nt"></description></span> <span class="nt"><link></span>http://example.org/<span class="nt"></link></span> <span class="nt"><pubDate></span>Sat, 07 Sep 2002 00:00:01 GMT<span class="nt"></pubDate></span> <span class="c"><!-- other elements omitted from this example --></span> <span class="nt"><item></span> <span class="nt"><title></span>First entry title<span class="nt"></title></span> <span class="nt"><link></span>http://example.org/entry/3<span class="nt"></link></span> <span class="nt"><description></span>Watch out for <span class="ni">&lt;</span>span style="background-image: url(javascript:window.location='http://example.org/')"<span class="ni">&gt;</span>nasty tricks<span class="ni">&lt;</span>/span<span class="ni">&gt;</span><span class="nt"></description></span> <span class="nt"><pubDate></span>Thu, 05 Sep 2002 00:00:01 GMT<span class="nt"></pubDate></span> <span class="nt"><guid></span>http://example.org/entry/3<span class="nt"></guid></span> <span class="c"><!-- other elements omitted from this example --></span> <span class="nt"></item></span> <span class="nt"></channel></span> <span class="nt"></rss></span> </pre></div> </div> <p>The channel elements are available in <tt class="docutils literal"><span class="pre">d.feed</span></tt>.</p> <div class="section" id="accessing-common-channel-elements"> <h2>Accessing Common Channel Elements<a class="headerlink" href="#accessing-common-channel-elements" title="Permalink to this headline">¶</a></h2> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">feedparser</span> <span class="gp">>>> </span><span class="n">d</span> <span class="o">=</span> <span class="n">feedparser</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s">'http://feedparser.org/docs/examples/rss20.xml'</span><span class="p">)</span> <span class="gp">>>> </span><span class="n">d</span><span class="o">.</span><span class="n">feed</span><span class="o">.</span><span class="n">title</span> <span class="go">u'Sample Feed'</span> <span class="gp">>>> </span><span class="n">d</span><span class="o">.</span><span class="n">feed</span><span class="o">.</span><span class="n">link</span> <span class="go">u'http://example.org/'</span> <span class="gp">>>> </span><span class="n">d</span><span class="o">.</span><span class="n">feed</span><span class="o">.</span><span class="n">description</span> <span class="go">u'For documentation <em>only</em>'</span> <span class="gp">>>> </span><span class="n">d</span><span class="o">.</span><span class="n">feed</span><span class="o">.</span><span class="n">published</span> <span class="go">u'Sat, 07 Sep 2002 00:00:01 GMT'</span> <span class="gp">>>> </span><span class="n">d</span><span class="o">.</span><span class="n">feed</span><span class="o">.</span><span class="n">published_parsed</span> <span class="go">(2002, 9, 7, 0, 0, 1, 5, 250, 0)</span> </pre></div> </div> <p>The items are available in <tt class="docutils literal"><span class="pre">d.entries</span></tt>, which is a list. You access items in the list in the same order in which they appear in the original feed, so the first item is available in <tt class="docutils literal"><span class="pre">d.entries[0]</span></tt>.</p> </div> <div class="section" id="accessing-common-item-elements"> <h2>Accessing Common Item Elements<a class="headerlink" href="#accessing-common-item-elements" title="Permalink to this headline">¶</a></h2> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">feedparser</span> <span class="gp">>>> </span><span class="n">d</span> <span class="o">=</span> <span class="n">feedparser</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s">'http://feedparser.org/docs/examples/rss20.xml'</span><span class="p">)</span> <span class="gp">>>> </span><span class="n">d</span><span class="o">.</span><span class="n">entries</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">title</span> <span class="go">u'First item title'</span> <span class="gp">>>> </span><span class="n">d</span><span class="o">.</span><span class="n">entries</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">link</span> <span class="go">u'http://example.org/item/1'</span> <span class="gp">>>> </span><span class="n">d</span><span class="o">.</span><span class="n">entries</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">description</span> <span class="go">u'Watch out for <span>nasty tricks</span>'</span> <span class="gp">>>> </span><span class="n">d</span><span class="o">.</span><span class="n">entries</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">published</span> <span class="go">u'Thu, 05 Sep 2002 00:00:01 GMT'</span> <span class="gp">>>> </span><span class="n">d</span><span class="o">.</span><span class="n">entries</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">published_parsed</span> <span class="go">(2002, 9, 5, 0, 0, 1, 3, 248, 0)</span> <span class="gp">>>> </span><span class="n">d</span><span class="o">.</span><span class="n">entries</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">id</span> <span class="go">u'http://example.org/guid/1'</span> </pre></div> </div> <div class="admonition tip"> <p class="first admonition-title">Tip</p> <p class="last">You can also access data from <abbr title="Rich Site Summary">RSS</abbr> feeds using Atom terminology. See <a class="reference internal" href="content-normalization.html#advanced-normalization"><em>Content Normalization</em></a> for details.</p> </div> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Common <abbr title="Rich Site Summary">RSS</abbr> Elements</a><ul> <li><a class="reference internal" href="#accessing-common-channel-elements">Accessing Common Channel Elements</a></li> <li><a class="reference internal" href="#accessing-common-item-elements">Accessing Common Item Elements</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="introduction.html" title="previous chapter">Introduction</a></p> <h4>Next topic</h4> <p class="topless"><a href="common-atom-elements.html" title="next chapter">Common Atom Elements</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="_sources/common-rss-elements.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="common-atom-elements.html" title="Common Atom Elements" >next</a> |</li> <li class="right" > <a href="introduction.html" title="Introduction" >previous</a> |</li> <li><a href="index.html">feedparser 5.1.3 documentation</a> »</li> <li><a href="basic.html" >Basic Features</a> »</li> </ul> </div> <div class="footer"> © Copyright 2004-2008 Mark Pilgrim, 2010-2012 Kurt McKee. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>