Read rss by feedparser
feedparserを利用して,rssを読み込みます.feedparserのダウンロードとインストール
- ダウンロード
- 解答とインストール
http://code.google.com/p/feedparser/から,feedparserをダウンロードする.
feedparser-5.0.1.tar.gzの場合:
% tar zxvf feedparser-5.0.1.tar.gz % cd feedparser-5.0.1 % python setup.py install
サンプルプログラム
#!/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
サンプルプログラム