2
我使用罗马图书馆的Java解析一些RSS。 默认情况下,它需要25个条目。罗马图书馆获取所有的RSS提要条目
请告诉我,如何获得下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();
}
}
谢谢!
真棒!谢谢!不幸的是,我无法评价你的答案(没有足够的声望) –