DZone: Your Personal Tech Universe Ruby Zone
Published on Ruby Zone (http://ruby.dzone.com)
Ruby RSS Aggregator
By palmerj3
Created 2008/01/26 - 2:26pm

RSS feeds offer everyone the ability to aggregate content and centralize the content that matters to you. Several sites offer RSS Aggregation already, so I will demonstrate how you can use Ruby to create your own RSS Aggregator in just a few minutes. With Ruby we can quickly create an RSS Aggregator using the Feed-Normalizer gem.

First, let's install the gem:

gem install feed-normalizer

Now that we have the gem installed, let's put together a simple script that will aggregate Slashdot's RSS Feed:

require 'rubygems'
require 'feed-normalizer'

#Define URL and Parse Feed
feed_url = 'http://rss.slashdot.org/Slashdot/slashdot'
rss = FeedNormalizer::FeedNormalizer.parse open(feed_url)

#Quit if no articles
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

#Your Logic Here
end

 

As you can see, it's quite simple to aggregate an RSS Feed using Ruby and Feed-Normalizer.

Article Type: 
How-to

Source URL: http://ruby.dzone.com/articles/ruby-rss-aggregator