使用罗马图书馆获取所有 RSS 提要条目 [英] Get all RSS feed entries with Rome Library

查看:41
本文介绍了使用罗马图书馆获取所有 RSS 提要条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

Tell me please, how to get next 25 entries?

我的测试代码是:

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

谢谢!

推荐答案

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

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).

这篇关于使用罗马图书馆获取所有 RSS 提要条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆