Friday, February 15, 2008

ruby rss aggregator using feed-normalizer

$> gem install feed-normalizer

require 'rubygems'
require 'feed-normalizer'

feed = 'http://googlechinablog.com/atom.xml'
rss = FeedNormalizer::FeedNormalizer.parse(open(feed))
exit unless rss.entries.length > 0
#Read entries
rss.entries.each do |entry|
title = entry.title
body = entry.content
authors = entry.authors.join(', ') rescue ''
entry_url = entry.urls.first
puts title, body, authors, entry_url
end
reference: http://ruby.dzone.com/articles/ruby-rss-aggregator

No comments :