<!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>Feed Type and Version Detection — 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="Advanced Features" href="advanced.html" /> <link rel="next" title="Character Encoding Detection" href="character-encoding.html" /> <link rel="prev" title="Relative Link Resolution" href="resolving-relative-links.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="character-encoding.html" title="Character Encoding Detection" accesskey="N">next</a> |</li> <li class="right" > <a href="resolving-relative-links.html" title="Relative Link Resolution" accesskey="P">previous</a> |</li> <li><a href="index.html">feedparser 5.1.3 documentation</a> »</li> <li><a href="advanced.html" accesskey="U">Advanced Features</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="feed-type-and-version-detection"> <h1>Feed Type and Version Detection<a class="headerlink" href="#feed-type-and-version-detection" title="Permalink to this headline">¶</a></h1> <p><strong class="program">Universal Feed Parser</strong> attempts to autodetect the type and version of the feeds it parses. There are many subtle and not-so-subtle differences between the different versions of <abbr title="Rich Site Summary">RSS</abbr>, and applications may choose to handle different feed types in different ways.</p> <div class="section" id="accessing-feed-version"> <h2>Accessing feed version<a class="headerlink" href="#accessing-feed-version" title="Permalink to this headline">¶</a></h2> <div class="highlight-python"><div class="highlight"><pre><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/atom10.xml'</span><span class="p">)</span> <span class="gp">>>> </span><span class="n">d</span><span class="o">.</span><span class="n">version</span> <span class="go">'atom10'</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/atom03.xml'</span><span class="p">)</span> <span class="gp">>>> </span><span class="n">d</span><span class="o">.</span><span class="n">version</span> <span class="go">'atom03'</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">version</span> <span class="go">'rss20'</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/rss20dc.xml'</span><span class="p">)</span> <span class="gp">>>> </span><span class="n">d</span><span class="o">.</span><span class="n">version</span> <span class="go">'rss20'</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/rss10.rdf'</span><span class="p">)</span> <span class="gp">>>> </span><span class="n">d</span><span class="o">.</span><span class="n">version</span> <span class="go">'rss10'</span> </pre></div> </div> <p>Here is the complete list of known feed types and versions that may be returned in <tt class="docutils literal"><span class="pre">version</span></tt>:</p> <dl class="docutils"> <dt><tt class="docutils literal"><span class="pre">rss090</span></tt></dt> <dd><a class="reference external" href="http://www.purplepages.ie/RSS/netscape/rss0.90.html">RSS 0.90</a></dd> <dt><tt class="docutils literal"><span class="pre">rss091n</span></tt></dt> <dd><a class="reference external" href="http://my.netscape.com/publish/formats/rss-spec-0.91.html">Netscape RSS 0.91</a></dd> <dt><tt class="docutils literal"><span class="pre">rss091u</span></tt></dt> <dd><a class="reference external" href="http://backend.userland.com/rss091">Userland RSS 0.91</a> (<a class="reference external" href="http://diveintomark.org/archives/2004/02/04/incompatible-rss#example3">differences from Netscape RSS 0.91</a>)</dd> <dt><tt class="docutils literal"><span class="pre">rss10</span></tt></dt> <dd><a class="reference external" href="http://purl.org/rss/1.0/">RSS 1.0</a></dd> <dt><tt class="docutils literal"><span class="pre">rss092</span></tt></dt> <dd><a class="reference external" href="http://backend.userland.com/rss092">RSS 0.92</a></dd> <dt><tt class="docutils literal"><span class="pre">rss093</span></tt></dt> <dd><a class="reference external" href="http://backend.userland.com/rss093">RSS 0.93</a></dd> <dt><tt class="docutils literal"><span class="pre">rss094</span></tt></dt> <dd><abbr title="Rich Site Summary">RSS</abbr> 0.94 (no accurate specification is known to exist)</dd> <dt><tt class="docutils literal"><span class="pre">rss20</span></tt></dt> <dd><a class="reference external" href="http://blogs.law.harvard.edu/tech/rss">RSS 2.0</a></dd> <dt><tt class="docutils literal"><span class="pre">rss</span></tt></dt> <dd><abbr title="Rich Site Summary">RSS</abbr> (unknown or unrecognized version)</dd> <dt><tt class="docutils literal"><span class="pre">atom01</span></tt></dt> <dd><a class="reference external" href="http://www.intertwingly.net/blog/1506.html">Atom 0.1</a></dd> <dt><tt class="docutils literal"><span class="pre">atom02</span></tt></dt> <dd><a class="reference external" href="http://diveintomark.org/public/2003/08/atom02spec.txt">Atom 0.2</a></dd> <dt><tt class="docutils literal"><span class="pre">atom03</span></tt></dt> <dd><a class="reference external" href="http://www.mnot.net/drafts/draft-nottingham-atom-format-02.html">Atom 0.3</a></dd> <dt><tt class="docutils literal"><span class="pre">atom10</span></tt></dt> <dd><a class="reference external" href="http://www.ietf.org/rfc/rfc4287">Atom 1.0</a></dd> <dt><tt class="docutils literal"><span class="pre">atom</span></tt></dt> <dd>Atom (unknown or unrecognized version)</dd> <dt><tt class="docutils literal"><span class="pre">cdf</span></tt></dt> <dd><a class="reference external" href="http://www.w3.org/TR/NOTE-CDFsubmit.html">CDF</a></dd> </dl> <p>If the feed type is completely unknown, <tt class="docutils literal"><span class="pre">version</span></tt> will be an empty string.</p> </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="#">Feed Type and Version Detection</a><ul> <li><a class="reference internal" href="#accessing-feed-version">Accessing feed version</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="resolving-relative-links.html" title="previous chapter">Relative Link Resolution</a></p> <h4>Next topic</h4> <p class="topless"><a href="character-encoding.html" title="next chapter">Character Encoding Detection</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="_sources/version-detection.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="character-encoding.html" title="Character Encoding Detection" >next</a> |</li> <li class="right" > <a href="resolving-relative-links.html" title="Relative Link Resolution" >previous</a> |</li> <li><a href="index.html">feedparser 5.1.3 documentation</a> »</li> <li><a href="advanced.html" >Advanced 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>