Python Text Processing - Reading RSS Feed
RSS (Rich Site Summary) is a format for delivering regularly changing web content. Many news-related sites, weblogs and other online publishers syndicate their content as an RSS Feed to whoever wants it. In python we take help of the below package to read and process these feeds.
pip install feedparser
Feed Structure
In the below example we get the structure of the feed so that we can analyse further about which parts of the feed we want to process.
main.py
import feedparser
NewsFeed = feedparser.parse("https://timesofindia.indiatimes.com/rssfeedstopstories.cms")
entry = NewsFeed.entries[1]
print entry.keys()
Output
When we run the above program, we get the following output
dict_keys(['title', 'title_detail', 'summary', 'summary_detail', 'links', 'link', 'id', 'guidislink', 'published', 'published_parsed', 'authors', 'author', 'author_detail'])
Feed Title and Posts
Reading Title and Head of RSS Feed
In the below example we read the title and head of the rss feed.
main.py
import feedparser
NewsFeed = feedparser.parse("https://timesofindia.indiatimes.com/rssfeedstopstories.cms")
print('Number of RSS posts :', len(NewsFeed.entries))
entry = NewsFeed.entries[1]
print('Post Title :',entry.title)
Output
When we run the above program we get the following output
Number of RSS posts : 47 Post Title : Why Saturday? How Israel-US strikes targeted Khamenei and his inner circle
Feed Details
Based on above entry structure we can derive the necessary details from the feed using python program as shown below. As entry is a dictionary we utilise its keys to produce the values needed.
main.py
import feedparser
NewsFeed = feedparser.parse("https://timesofindia.indiatimes.com/rssfeedstopstories.cms")
entry = NewsFeed.entries[1]
print(entry.published)
print("******")
print(entry.summary)
print("------News Link--------")
print(entry.link)
Output
When we run the above program we get the following output
Sun, 01 Mar 2026 12:15:06 +0530 ****** Iran launched retaliatory strikes across key Gulf cities, including Dubai, Doha, and Manama, targeting areas hosting US military bases. These attacks followed US and Israeli strikes that reportedly killed Iran's Supreme Leader. Major airports experienced evacuations and flight suspensions due to the escalating regional conflict. ------News Link-------- https://timesofindia.indiatimes.com/world/middle-east /iran-strikes-gulf-again-more-explosions-in-dubai-doha-and-manama-airports-targeted/ articleshow/128908100.cms