Sitemap
Vivek Sahani

Vivek Sahani

Create a RSS Feed Reader using python

2 min readFeb 29, 2024

RSS Feed is nothing but news data which is in XML format.

For reading RSS XML I’m using feedparser library of Python. Using this library first we parse the XML data and display it on the webpage.

I’m using Flask Framework of Python to serve static sites, fetching and parsing XML

Press enter or click to view image in full size
  1. Install the feedparser library
pip install feedparser

2. Import feedparser and some necessary libraries to create a Flask App

3. Create an array for RSS XML providers in my case I’ve only two Providers wired.com and nsnam.org

Get Vivek Sahani’s stories in your inbox

Join Medium for free to get updates from this writer.

4. Loop through the urls and parse the RSS, get the entries field of dictionaries and store it in data array.

data.append(feedparser.parse(url)['entries']

feedparser.parse() method will parse the feed and return the root element

5. Now pass that data to your HTML template and display the content on the Page.

Press enter or click to view image in full size
HTML Content

6. Loop through the data Each articles in articles_data has multiple entries and each entries have a title, description and link field. I’m using the Jinja2 template in this template we use {{}} to access the variables.

7. Now run the Flask server

Press enter or click to view image in full size
Result

Link: https://rss-feed-reader-flask.vercel.app/
Code: https://github.com/VivekSite/rss-feed-reader-flask

So, It’s a very simple feed reader that show’s title, description and button for reading more, This project is just for showing how we can use feedparser library to read RSS Feeds using Python

--

--