我找到了答案。 如果不通過羅馬API,閱讀rss提要的唯一方法是。您需要獲取該Feed新聞的ulr,如下所示:
com.sun.syndication.feed.synd.SyndEntry entry = //get from RSS Url using rome api
String link=entry.getLink();
URL res = new URL(url);
Document doc = Jsoup.connect(url).get();
URL res = new URL(url); Document doc = Jsoup.connect(url).get();
URL res = new URL(url);
Document doc = Jsoup.connect(url).get();
Element head = doc.head();
Elements titleTags = head.getElementsByTag("title");
if (!titleTags.isEmpty()) {
title = titleTags.text();
} else {
Elements metaTitle = head.select("meta[property=og:title]");
title = metaTitle.attr("content");
if (metaTitle.isEmpty()) {
Elements metaTitle = head.select("meta[name=twitter:title]");
title = metaTitle.attr("content");
}
}
String description = "";
Elements metaDescription = head.select("meta[name=description]");
if (!metaDescription.isEmpty()) {
description = metaDescription.attr("content");
} else {
Elements metaDescription = head.select("meta[property=og:description]");
if (!metaDescriptionFacebook.isEmpty()) {
description = metaDescriptionFacebook.attr("content");
} else {
metaDescription = head.select("meta[name=twitter:description]");
description = metaDescription.attr("content");
}
}
return description;
String previewUrl = "";
Elements metaImage = head.select("link[rel=image_src]");
if (!metaImage.isEmpty()) {
previewUrl = metaImage.first().absUrl("href");
} else {
Elements metaImage= head.select("meta[property=og:image]");
if (!metaImageFacebook.isEmpty() && StringUtils.isNotBlank(metaImage.attr("content"))) {
previewUrl = metaImage.first().absUrl("content");
} else {
Elements metaImage = head.select("meta[name=twitter:image]");
if (!metaImage.isEmpty() && StringUtils.isNotBlank(metaImage.attr("content"))) {
previewUrl = metaImage.first().absUrl("content");
}
}
}
您可以從Doc元素中獲得更多內容,例如視頻,音頻等。