Get all RSS feed entries with Rome Library

2019-07-14 06:22发布

i am using Rome library for Java to parse some RSS. By default it takes 25 entries.

Tell me please, how to get next 25 entries?

My test code is:

public static SyndFeed getSyndFeedForUrl(String url) throws Exception {

    SyndFeed feed = null;
    InputStream is = null;

    try {

        URLConnection openConnection = new URL(url).openConnection();
        is = new URL(url).openConnection().getInputStream();
        if("gzip".equals(openConnection.getContentEncoding())){
            is = new GZIPInputStream(is);
        }
        InputSource source = new InputSource(is);
        SyndFeedInput input = new SyndFeedInput();
        feed = input.build(source);

    } catch (Exception e){
        e.printStackTrace();
    } finally {
        if( is != null) is.close();
    }

    return feed;
}

public static void main(String[] args) {
        SyndFeed feed;
        try {
            feed = getSyndFeedForUrl("http://example.com/rss");
            List res = feed.getEntries();
            for(Object o : res) {
                System.out.println(((SyndEntryImpl) o).getDescription().getValue());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

Thank you!

标签: java rss rome
1条回答
三岁会撩人
2楼-- · 2019-07-14 06:55

When you call feed.getEntries(), Rome library returns all entries that are available in http://example.com/rss. It is not possible to get more than there are in the xml document (unless the entries have been cached in some service like Feedly).

See

查看更多
登录 后发表回答