use of org.jsoup.select.Selector.SelectorParseException in project Lightning-Browser by anthonycr.
the class ArticleTextExtractor method extractAuthorDescription.
// Returns the author description or null
private String extractAuthorDescription(Document doc, String authorName) {
String authorDesc = "";
if (authorName.isEmpty())
return "";
// Special case for entrepreneur.com
Elements matches = doc.select(".byline > .bio");
if (matches != null && !matches.isEmpty()) {
// assume it is the first.
Element bestMatch = matches.first();
authorDesc = bestMatch.text();
return authorDesc;
}
// Special case for huffingtonpost.com
matches = doc.select(".byline span[class*=teaser]");
if (matches != null && !matches.isEmpty()) {
// assume it is the first.
Element bestMatch = matches.first();
authorDesc = bestMatch.text();
return authorDesc;
}
try {
Elements nodes = doc.select(":containsOwn(" + authorName + ')');
Element bestMatch = getBestMatchElement(nodes);
if (bestMatch != null)
authorDesc = bestMatch.text();
} catch (SelectorParseException se) {
// Avoid error when selector is invalid
}
return authorDesc;
}
Aggregations