Get all RSS feed entries with Rome Library

六月ゝ 毕业季﹏ 提交于 2019-12-11 00:09:18

问题


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!


回答1:


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

  • How to get all the posts from rss feed rather than the latest posts?
  • How to get more feeds from RSS url?
  • How Do I Fetch All Old Items on an RSS Feed?


来源:https://stackoverflow.com/questions/33764251/get-all-rss-feed-entries-with-rome-library

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!