RSS / ATOM Feed Parsing in Python

Feeds are good for showing content from one website to another. Feeds are basically XML file with user define tags. As Python fan, I found reading content from a RSS feed in python is very simple and interesting. Most of the sites have feeds.

In our example we are using SEBI’s feed, which will provide latest events in Indian Stock Exchange market.

First you need the parsing package from Pypi[Python Package Index]. You can Install the package using pip command as follows

pip install feedparser

Import the package and use it

import feedparser
#Programmer : MANOJ AP
feed = feedparser.parse("")

feed_title = feed['feed']['title']
feed_entries = feed.entries

for entry in feed.entries:
    article_title = entry.title
    article_link =
    article_published_at = entry.published # Unicode string
    article_published_at_parsed = entry.published_parsed # Time object  
    print "{}[{}]".format(article_title.encode('utf-8'), article_link.encode('utf-8'))
    print "Published at {}" .format(article_published_at)

TheĀ feedparser.parse accept a RSS feed and turn into Python object, as we know can access the elements in as in a list(feed[‘feed’][‘title’]). feed.entries return the feed elements, we can use a for loop to traverse through the elements

You are welcome to use the source code, SEBI Reader project

Published by


A developer,teacher and a blogger obsessed with Python,Dart and open source world from India

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.