Rome is a new java API for reading RSS and ATOM feeds. Here is a quick demonstration of what you can do with it using Jython, the Java Scripting Swiss Army Knife.
Ok, you will need to add both the latest build of Rome and JDOM to your classpath. Next fire up jython or if you like use the Jython Console which will make exploring the ROME api a little easier.
Here is the source code then of a simple aggregator written in jython.
from java.net import URL
from com.sun.syndication.feed.synd import SyndFeedI
from com.sun.syndication.io import SyndFeedInput
myUrl = URL('http://www.pycs.net/users/0000177/rss.xml')
input = SyndFeedInput()
feed = input.build(myUrl.openStream())
entries = feed.getEntries()
for post in entries:
title = post.getTitle()
link = post.getLink()
print """<a href='%s'>%s</a>""" % (title, link)
When you run this, you will get a list of links pointing to the posts in the feed, in this case the feed for my main site.
|