Sophie

Sophie

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

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>Common 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="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> &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="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">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span>
<span class="nt">&lt;rss</span> <span class="na">version=</span><span class="s">&quot;2.0&quot;</span><span class="nt">&gt;</span>
<span class="nt">&lt;channel&gt;</span>
<span class="nt">&lt;title&gt;</span>Sample Feed<span class="nt">&lt;/title&gt;</span>
<span class="nt">&lt;description&gt;</span>For documentation <span class="ni">&amp;lt;</span>em<span class="ni">&amp;gt;</span>only<span class="ni">&amp;lt;</span>/em<span class="ni">&amp;gt;</span><span class="nt">&lt;/description&gt;</span>
<span class="nt">&lt;link&gt;</span>http://example.org/<span class="nt">&lt;/link&gt;</span>
<span class="nt">&lt;pubDate&gt;</span>Sat, 07 Sep 2002 00:00:01 GMT<span class="nt">&lt;/pubDate&gt;</span>
<span class="c">&lt;!-- other elements omitted from this example --&gt;</span>
<span class="nt">&lt;item&gt;</span>
<span class="nt">&lt;title&gt;</span>First entry title<span class="nt">&lt;/title&gt;</span>
<span class="nt">&lt;link&gt;</span>http://example.org/entry/3<span class="nt">&lt;/link&gt;</span>
<span class="nt">&lt;description&gt;</span>Watch out for <span class="ni">&amp;lt;</span>span style=&quot;background-image:
url(javascript:window.location=&#39;http://example.org/&#39;)&quot;<span class="ni">&amp;gt;</span>nasty
tricks<span class="ni">&amp;lt;</span>/span<span class="ni">&amp;gt;</span><span class="nt">&lt;/description&gt;</span>
<span class="nt">&lt;pubDate&gt;</span>Thu, 05 Sep 2002 00:00:01 GMT<span class="nt">&lt;/pubDate&gt;</span>
<span class="nt">&lt;guid&gt;</span>http://example.org/entry/3<span class="nt">&lt;/guid&gt;</span>
<span class="c">&lt;!-- other elements omitted from this example --&gt;</span>
<span class="nt">&lt;/item&gt;</span>
<span class="nt">&lt;/channel&gt;</span>
<span class="nt">&lt;/rss&gt;</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">&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">title</span>
<span class="go">u&#39;Sample Feed&#39;</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">link</span>
<span class="go">u&#39;http://example.org/&#39;</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">description</span>
<span class="go">u&#39;For documentation &lt;em&gt;only&lt;/em&gt;&#39;</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">published</span>
<span class="go">u&#39;Sat, 07 Sep 2002 00:00:01 GMT&#39;</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">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">&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">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&#39;First item title&#39;</span>
<span class="gp">&gt;&gt;&gt; </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&#39;http://example.org/item/1&#39;</span>
<span class="gp">&gt;&gt;&gt; </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&#39;Watch out for &lt;span&gt;nasty tricks&lt;/span&gt;&#39;</span>
<span class="gp">&gt;&gt;&gt; </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&#39;Thu, 05 Sep 2002 00:00:01 GMT&#39;</span>
<span class="gp">&gt;&gt;&gt; </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">&gt;&gt;&gt; </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&#39;http://example.org/guid/1&#39;</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> &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>