mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
parse fetched result only if it's html
This commit is contained in:
@@ -59,17 +59,19 @@ public class FeedFetcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String extractFeedUrl(String html) {
|
private String extractFeedUrl(String html) {
|
||||||
|
String foundUrl = null;
|
||||||
|
|
||||||
Document doc = Jsoup.parse(html);
|
Document doc = Jsoup.parse(html);
|
||||||
Elements rss = doc.select("link[type=application/rss+xml]");
|
String root = doc.children().get(0).tagName();
|
||||||
Elements atom = doc.select("link[type=application/atom+xml]");
|
if ("html".equals(root)) {
|
||||||
|
Elements rss = doc.select("link[type=application/rss+xml]");
|
||||||
if (rss.size() > 0) {
|
Elements atom = doc.select("link[type=application/atom+xml]");
|
||||||
return rss.get(0).attr("abs:href").toString();
|
if (!rss.isEmpty()) {
|
||||||
} else if (atom.size() > 0) {
|
foundUrl = rss.get(0).attr("abs:href").toString();
|
||||||
return atom.get(0).attr("abs:href").toString();
|
} else if (!atom.isEmpty()) {
|
||||||
} else {
|
foundUrl = atom.get(0).attr("abs:href").toString();
|
||||||
return null;
|
}
|
||||||
}
|
}
|
||||||
|
return foundUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user