Tropical Software Observations

09 January 2009

Posted by Teo Choong Ping

at 5:59 PM

0 comments

Labels: , , ,

Consume RSS Feeds easily with Groovy and Rome

This is what I did to start consuming RSS feeds with Groovy within 20 minutes!

1. Download Rome.
2. Download Rome Fetcher.
3. Download JDOM is you haven't done so.
4. Extract rome-x.jar, rom-fetcher-x.jar and jdom.jar to a tmp directory -- I placed them in lib/.
5. Start your Groovy console with the classpath set to the jar files, like this:
$ groovyConsole -cp lib/rome-1.0RC1.jar:lib/rome-fetcher-0.9.jar:lib/jdom.jar
6. Use the code below:


import com.sun.syndication.fetcher.*
import com.sun.syndication.fetcher.impl.*
import com.sun.syndication.feed.synd.SyndFeed


FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getInstance();
FeedFetcher feedFetcher = new HttpURLFeedFetcher(feedInfoCache);
SyndFeed feed = feedFetcher.retrieveFeed(new URL("http://feeds.digg.com/digg/topic/programming/popular.rss"));


feed.entries.each {
println " -> ${it} "
}

println " == ${feed.entries?.size()}"


7. Finally, start reading the below docs:

0 comments: