python script to fetch rss feeds

I was just thinking about making an rss bot in telegram, and wrote a small python script which can fetch rss feeds from the feed link and prints the result with “Title” and “Link”.

import feedparser
import sys

if len(sys.argv) < 2:
print("USAGE: python feedparse.py <rss feed link>")
exit()

rss_url = sys.argv[1]
print("TITLE","                                                   ","LINK")
print("------------------------------------------------------------------")

feed = feedparser.parse( rss_url )

y = len(feed[ "items" ])

for x in range(0,y):
print('\033[91m'+feed[ "items" ][x][ "title" ] + '\033[0m', "-", feed[ "items" ][x][ "link" ])

Below example shall print the feeds available in Mobilecrunch.

Example:
$ python feedparse.py http://feeds.feedburner.com/Mobilecrunch

Newest code will be available in gist if I forget to update this blog.

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s