Python Network Programming Resources

Python Network - 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.

pip3 install feedparser

Feed Structure

In the below example we get the structure of the feed so that we can analyze 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 of 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 : 45
Post Title : 'Provided logistics' for 'shirtless' protest: 
Why Delhi Police arrested youth Congress chief

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 utilize 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 −

Tue, 24 Feb 2026 11:15:29 +0530
******
Delhi Police arrested Indian Youth Congress chief Uday Bhanu Chib and seven others for a shirtless protest at 
Bharat Mandapam during the AI Summit. The Youth Congress condemned the arrests as "an undeclared emergency," 
while Congress spokesperson Pawan Khera criticized the government's reaction to peaceful dissent. Protesters displayed anti-PM slogans.
------News Link--------
...
Advertisements