version-detection.rst 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. Feed Type and Version Detection
  2. ===============================
  3. :program:`Universal Feed Parser` attempts to autodetect the type and version of
  4. the feeds it parses. There are many subtle and not-so-subtle differences
  5. between the different versions of :abbr:`RSS (Rich Site Summary)`, and
  6. applications may choose to handle different feed types in different ways.
  7. Accessing feed version
  8. ----------------------
  9. ::
  10. >>> d = feedparser.parse('http://feedparser.org/docs/examples/atom10.xml')
  11. >>> d.version
  12. 'atom10'
  13. >>> d = feedparser.parse('http://feedparser.org/docs/examples/atom03.xml')
  14. >>> d.version
  15. 'atom03'
  16. >>> d = feedparser.parse('http://feedparser.org/docs/examples/rss20.xml')
  17. >>> d.version
  18. 'rss20'
  19. >>> d = feedparser.parse('http://feedparser.org/docs/examples/rss20dc.xml')
  20. >>> d.version
  21. 'rss20'
  22. >>> d = feedparser.parse('http://feedparser.org/docs/examples/rss10.rdf')
  23. >>> d.version
  24. 'rss10'
  25. Here is the complete list of known feed types and versions that may be returned in ``version``:
  26. ``rss090``
  27. `RSS 0.90 <http://www.purplepages.ie/RSS/netscape/rss0.90.html>`_
  28. ``rss091n``
  29. `Netscape RSS 0.91 <http://my.netscape.com/publish/formats/rss-spec-0.91.html>`_
  30. ``rss091u``
  31. `Userland RSS 0.91 <http://backend.userland.com/rss091>`_ (`differences from Netscape RSS 0.91 <http://diveintomark.org/archives/2004/02/04/incompatible-rss#example3>`_)
  32. ``rss10``
  33. `RSS 1.0 <http://purl.org/rss/1.0/>`_
  34. ``rss092``
  35. `RSS 0.92 <http://backend.userland.com/rss092>`_
  36. ``rss093``
  37. `RSS 0.93 <http://backend.userland.com/rss093>`_
  38. ``rss094``
  39. :abbr:`RSS (Rich Site Summary)` 0.94 (no accurate specification is known to exist)
  40. ``rss20``
  41. `RSS 2.0 <http://blogs.law.harvard.edu/tech/rss>`_
  42. ``rss``
  43. :abbr:`RSS (Rich Site Summary)` (unknown or unrecognized version)
  44. ``atom01``
  45. `Atom 0.1 <http://www.intertwingly.net/blog/1506.html>`_
  46. ``atom02``
  47. `Atom 0.2 <http://diveintomark.org/public/2003/08/atom02spec.txt>`_
  48. ``atom03``
  49. `Atom 0.3 <http://www.mnot.net/drafts/draft-nottingham-atom-format-02.html>`_
  50. ``atom10``
  51. `Atom 1.0 <http://www.ietf.org/rfc/rfc4287>`_
  52. ``atom``
  53. Atom (unknown or unrecognized version)
  54. ``cdf``
  55. `CDF <http://www.w3.org/TR/NOTE-CDFsubmit.html>`_
  56. If the feed type is completely unknown, ``version`` will be an empty string.