问题
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