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) {
|
||||
String foundUrl = null;
|
||||
|
||||
Document doc = Jsoup.parse(html);
|
||||
Elements rss = doc.select("link[type=application/rss+xml]");
|
||||
Elements atom = doc.select("link[type=application/atom+xml]");
|
||||
|
||||
if (rss.size() > 0) {
|
||||
return rss.get(0).attr("abs:href").toString();
|
||||
} else if (atom.size() > 0) {
|
||||
return atom.get(0).attr("abs:href").toString();
|
||||
} else {
|
||||
return null;
|
||||
String root = doc.children().get(0).tagName();
|
||||
if ("html".equals(root)) {
|
||||
Elements rss = doc.select("link[type=application/rss+xml]");
|
||||
Elements atom = doc.select("link[type=application/atom+xml]");
|
||||
if (!rss.isEmpty()) {
|
||||
foundUrl = rss.get(0).attr("abs:href").toString();
|
||||
} else if (!atom.isEmpty()) {
|
||||
foundUrl = atom.get(0).attr("abs:href").toString();
|
||||
}
|
||||
}
|
||||
return foundUrl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user