Read rss by feedparser

A sample program reads entries of rss by feedparser.

Download & install

  1. Download

  2. Download feedparser from http://code.google.com/p/feedparser/.

  3. Install

  4. For feedparser-5.0.1.tar.gz:
     % tar zxvf feedparser-5.0.1.tar.gz
     % cd feedparser-5.0.1
     % python setup.py install
    

Sample program

#!/usr/bin/python
#coding: utf-8

import feedparser

rssurl="http://searchranking.yahoo.co.jp/rss/burst_ranking-rss.xml"
fdp = feedparser.parse(rssurl)

print fdp['channel'].title.encode('utf_8')
print fdp['channel'].link
print
print

for entry in fdp['entries']:
	if( 'title' in entry ):
		title = entry['title']
		print 'title:'+title.encode('utf_8')
	if( 'link' in entry ):
		link = entry['link']
		print 'link:'+link.encode('utf_8')
	if( 'description' in entry ):
		description = entry['description']
		print 'description:'+description.encode('utf_8')
	if( 'date' in entry ):
		date = entry['date']
		print 'date:'+date.encode('utf_8')
	print
Sample program