使用罗马图书馆获取所有 RSS 提要条目

Ily*_*kov 2 java rss rome

我正在使用 Java 的罗马库来解析一些 RSS。默认情况下,它需要 25 个条目。

请告诉我,如何获得接下来的 25 个条目?

我的测试代码是:

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();
        }
    }
Run Code Online (Sandbox Code Playgroud)

谢谢!

jan*_*nih 5

当您调用时feed.getEntries(),Rome 库将返回http://example.com/rss. 不可能获得超过 xml 文档中的内容(除非条目已缓存在某些服务中,例如 Feedly)。