1

How would I go about fetching stories with rome.

i.e. I have the feed how to get an updated version of the feed.

I am currently calling:

    URL url = new URL("http://feeds.bbci.co.uk/news/rss.xml");
    XmlReader reader = null;
    SyndFeedInput input = new SyndFeedInput();

    try{
        reader = new XmlReader(url);
        SyndFeed feed = input.build(reader);
        parseFeed(feed);
    }
    finally {
              if (reader != null)
                  reader.close();
    }
Alex
  • 690
  • 1
  • 9
  • 29

2 Answers2

0

I think this is what your are looking for:

FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getInstance();
FeedFetcher feedFetcher = new HttpURLFeedFetcher(feedInfoCache);
SyndFeed feed = feedFetcher.retrieveFeed(new URL("http://blogs.oracle.com/roller/rss/pat"));
System.out.println(feed);

Any subsequent fetches of http://blogs.oracle.com/roller/rss/pat by any FeedFetcher using feedInfoCache will now only retrieve the feed if it has changed.

To update your feeds call: feed = feedFetcher.retrieveFeed(new URL("http://blogs.oracle.com/roller/rss/pat"));

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Elia Palme
  • 161
  • 1
  • 12
0

The RSS feed will give you the latest stories about Rome already [such is the nature of RSS feeds]. If you want to update that periodically, you should probably run your code periodically

iluxa
  • 6,941
  • 18
  • 36
  • So the SyndFeed object is automatically refreshed. Or do I need to rebuild it? – Alex Mar 12 '11 at 11:51
  • The actual content of "http://feeds.bbci.co.uk/news/rss.xml" will be automatically refreshed (just open it in the browser over a couple of days and you'll see). Whenever you run the code, you'll grab the current version of it. – iluxa Mar 14 '11 at 19:22