开发者

Periodically updating rss feed in rome

开发者 https://www.devze.com 2023-02-16 20:51 出处:网络
How would I go about fetching stories with rome. i.e. I have the feed how to get an updated version of the feed.

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();
    }


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


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"));

0

精彩评论

暂无评论...
验证码 换一张
取 消