Ruby RSS Aggregator
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.
- Login or register to post comments
- 1576 reads
- Printer-friendly version
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)






