Over a million developers have joined DZone.

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.

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}