Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > 7e03e96dde1cbbdbc7cc96424cd9e059 > files > 396

python-feedparser-doc-5.1.3-3.fc18.noarch.rpm



<!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>Uncommon RSS Elements &mdash; 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="Uncommon Atom Elements" href="uncommon-atom.html" />
    <link rel="prev" title="Getting Detailed Information on Atom Elements" href="atom-detail.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="uncommon-atom.html" title="Uncommon Atom Elements"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="atom-detail.html" title="Getting Detailed Information on Atom Elements"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">feedparser 5.1.3 documentation</a> &raquo;</li>
          <li><a href="basic.html" accesskey="U">Basic Features</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="uncommon-rss-elements">
<h1>Uncommon <abbr title="Rich Site Summary">RSS</abbr> Elements<a class="headerlink" href="#uncommon-rss-elements" title="Permalink to this headline">¶</a></h1>
<p>These elements are less common, but are useful for niche applications and may
be present in any <abbr title="Rich Site Summary">RSS</abbr> feed.</p>
<p>An <abbr title="Rich Site Summary">RSS</abbr> feed can specify a small image which some
aggregators display as a logo.</p>
<div class="section" id="accessing-feed-image">
<h2>Accessing feed image<a class="headerlink" href="#accessing-feed-image" title="Permalink to this headline">¶</a></h2>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">feedparser</span>
<span class="gp">&gt;&gt;&gt; </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">&#39;http://feedparser.org/docs/examples/rss20.xml&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">feed</span><span class="o">.</span><span class="n">image</span>
<span class="go">{&#39;title&#39;: u&#39;Example banner&#39;,</span>
<span class="go">&#39;href&#39;: u&#39;http://example.org/banner.png&#39;,</span>
<span class="go">&#39;width&#39;: 80,</span>
<span class="go">&#39;height&#39;: 15,</span>
<span class="go">&#39;link&#39;: u&#39;http://example.org/&#39;}</span>
</pre></div>
</div>
<p>Feeds and entries can be assigned to multiple categories, and in some versions
of <abbr title="Rich Site Summary">RSS</abbr>, categories can be associated with a
&#8220;domain&#8221;.  Both are free-form strings.  For historical reasons,
<strong class="program">Universal Feed Parser</strong> makes multiple categories available as a list
of tuples, rather than a list of dictionaries.</p>
</div>
<div class="section" id="accessing-multiple-categories">
<h2>Accessing multiple categories<a class="headerlink" href="#accessing-multiple-categories" title="Permalink to this headline">¶</a></h2>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">feedparser</span>
<span class="gp">&gt;&gt;&gt; </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">&#39;http://feedparser.org/docs/examples/rss20.xml&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">feed</span><span class="o">.</span><span class="n">categories</span>
<span class="go">[(u&#39;Syndic8&#39;, u&#39;1024&#39;),</span>
<span class="go">(u&#39;dmoz&#39;, &#39;Top/Society/People/Personal_Homepages/P/&#39;)]</span>
</pre></div>
</div>
<p>Each item in an <abbr title="Rich Site Summary">RSS</abbr> feed can have an &#8220;enclosure&#8221;, 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 &#8220;enclosed&#8221;).  Once rare, this
element has recently gained popularity due to the rise of
<a class="reference external" href="http://en.wikipedia.org/wiki/Podcasting">podcasting</a>.  Some clients (such
as Apple&#8217;s <strong class="program">iTunes</strong>) may automatically download enclosures; others
(such as the web-based Bloglines) may simply render each enclosure as a link.</p>
<p>The <abbr title="Rich Site Summary">RSS</abbr> specification states that there can be at
most one enclosure per item.  However, Atom entries may contain more than one
enclosure per entry, so <strong class="program">Universal Feed Parser</strong> captures all of them
and makes them available as a list.</p>
</div>
<div class="section" id="accessing-enclosures">
<h2>Accessing enclosures<a class="headerlink" href="#accessing-enclosures" title="Permalink to this headline">¶</a></h2>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">feedparser</span>
<span class="gp">&gt;&gt;&gt; </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">&#39;http://feedparser.org/docs/examples/rss20.xml&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">e</span> <span class="o">=</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="gp">&gt;&gt;&gt; </span><span class="nb">len</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">enclosures</span><span class="p">)</span>
<span class="go">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">e</span><span class="o">.</span><span class="n">enclosures</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="go">{&#39;type&#39;: u&#39;audio/mpeg&#39;,</span>
<span class="go">&#39;length&#39;: u&#39;1069871&#39;,</span>
<span class="go">&#39;href&#39;: u&#39;http://example.org/audio/demo.mp3&#39;}</span>
</pre></div>
</div>
</div>
<div class="section" id="accessing-feed-cloud">
<h2>Accessing feed cloud<a class="headerlink" href="#accessing-feed-cloud" title="Permalink to this headline">¶</a></h2>
<p>No one is quite sure what a cloud is.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">feedparser</span>
<span class="gp">&gt;&gt;&gt; </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">&#39;http://feedparser.org/docs/examples/rss20.xml&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">feed</span><span class="o">.</span><span class="n">cloud</span>
<span class="go">{&#39;domain&#39;: u&#39;rpc.example.com&#39;,</span>
<span class="go">&#39;port&#39;: u&#39;80&#39;,</span>
<span class="go">&#39;path&#39;: u&#39;/RPC2&#39;,</span>
<span class="go">&#39;registerprocedure&#39;: u&#39;pingMe&#39;,</span>
<span class="go">&#39;protocol&#39;: u&#39;soap&#39;}</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">For more examples of accessing <abbr title="Rich Site Summary">RSS</abbr> elements,
see the annotated examples: <a class="reference internal" href="annotated-rss10.html#annotated-rss10"><em>RSS 1.0</em></a>, <a class="reference internal" href="annotated-rss20.html#annotated-rss20"><em>RSS 2.0</em></a>,
and <a class="reference internal" href="annotated-rss20-dc.html#annotated-rss20dc"><em>RSS 2.0 with Namespaces</em></a>.</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="#">Uncommon <abbr title="Rich Site Summary">RSS</abbr> Elements</a><ul>
<li><a class="reference internal" href="#accessing-feed-image">Accessing feed image</a></li>
<li><a class="reference internal" href="#accessing-multiple-categories">Accessing multiple categories</a></li>
<li><a class="reference internal" href="#accessing-enclosures">Accessing enclosures</a></li>
<li><a class="reference internal" href="#accessing-feed-cloud">Accessing feed cloud</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="atom-detail.html"
                        title="previous chapter">Getting Detailed Information on Atom Elements</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="uncommon-atom.html"
                        title="next chapter">Uncommon Atom Elements</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/uncommon-rss.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="uncommon-atom.html" title="Uncommon Atom Elements"
             >next</a> |</li>
        <li class="right" >
          <a href="atom-detail.html" title="Getting Detailed Information on Atom Elements"
             >previous</a> |</li>
        <li><a href="index.html">feedparser 5.1.3 documentation</a> &raquo;</li>
          <li><a href="basic.html" >Basic Features</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; 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>