Atom, RSS and JSON feed parser for Python 3
MIT License
.. image:: https://github.com/NicolasLM/atoma/actions/workflows/test.yml/badge.svg :target: https://github.com/NicolasLM/atoma/actions/workflows/test.yml .. image:: https://codecov.io/gh/NicolasLM/atoma/branch/main/graph/badge.svg :target: https://codecov.io/gh/NicolasLM/atoma
Atom, RSS and JSON feed parser for Python 3.
Install Atoma with pip::
pip install atoma
Load and parse an Atom XML file:
.. code:: python
>>> import atoma
>>> feed = atoma.parse_atom_feed('atom-feed.xml')
>>> feed.description
'The blog relating the daily life of web agency developers'
>>> len(feed.items)
5
A small change is needed if you are dealing with an RSS XML file:
.. code:: python
>>> feed = atoma.parse_rss_feed('rss-feed.xml')
Parsing feeds from the Internet is easy as well:
.. code:: python
>>> import atoma, requests
>>> response = requests.get('http://lucumr.pocoo.org/feed.atom')
>>> feed = atoma.parse_atom_bytes(response.content)
>>> feed.title.value
"Armin Ronacher's Thoughts and Writings"
RSS 2.0 Specification <http://cyber.harvard.edu/rss/rss.html>
_RFC4287 <https://tools.ietf.org/html/rfc4287>
_JSON Feed specification <https://jsonfeed.org/version/1>
_OPML 2.0 <http://dev.opml.org/spec2.html>
_If you use this library to display content from feeds in a web page, you NEED
to clean the HTML contained in the feeds to prevent Cross-site scripting (XSS) <https://en.wikipedia.org/wiki/Cross-site_scripting>
. The bleach <https://github.com/mozilla/bleach>
library is recommended for cleaning feeds.
To use this library a basic understanding of feeds is required. For Atom, the
Introduction to Atom <https://validator.w3.org/feed/docs/atom.html>
_ is a must
read. The RFC 4287 <https://tools.ietf.org/html/rfc4287>
_ can help lift some
ambiguities. Finally the feed validator <https://validator.w3.org/feed/>
_ is
great to test hand-crafted feeds.
For RSS, the RSS specification <http://cyber.harvard.edu/rss/rss.html>
_ and
rssboard.org <http://www.rssboard.org>
_ have a ton of information and
examples.
For OPML, the OPML specification <http://dev.opml.org/spec2.html#subscriptionLists>
_ has a paragraph dedicated
to its usage for syndication
Some seldom used features are not implemented:
text
, html
and xhtml
MIT