我正在使用 Java 的 Rome 库来解析一些 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();
}
}
谢谢你!
你打电话时feed.getEntries()
,罗马图书馆返回所有可用的条目http://example.com/rss
。不可能获得比 xml 文档中更多的内容(除非条目已缓存在某些服务(如 Feedly)中)。
See
- 如何从 rss feed 获取所有帖子而不是最新帖子? https://stackoverflow.com/questions/5962017/how-to-get-all-the-posts-from-rss-feed-rather-than-the-latest-posts
- 如何从 RSS url 获取更多提要? https://stackoverflow.com/questions/24110170/how-to-get-more-feeds-from-rss-url?rq=1
- 如何获取 RSS 源上的所有旧项目? https://stackoverflow.com/questions/576552/how-do-i-fetch-all-old-items-on-an-rss-feed?answertab=votes#tab-top
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)