List of utility methods to do HTML Jsoup Element
String | getSrcOrRelFromImageElement(Element imgElm) get Src Or Rel From Image Element if (imgElm.hasAttr("src")) return imgElm.attr("src"); return imgElm.attr("rel"); |
String | getString(Elements td, int i) get String return td.get(i).text();
|
String | getTextContent(Element node) getTextContent avoid NullReferenceException return (node == null) ? null : node.text();
|
String | getTextFromAClass(Element doc, String location) get Text From A Class Element elementByItemprop = doc.select("a[class=" + location + "]").first(); String result = (elementByItemprop != null) ? elementByItemprop.text() : "none"; return result; |
String | getTextFromMultipleSelect(Element doc, String location, String locationValue) get Text From Multiple Select String[] locations = location.split(","); String[] locationValues = locationValue.split(","); Element currentElement = doc; int counter = 0; for (int i = 0; i < (locations.length); i = +2) { if (currentElement == null) { break; } else { ... |
String | getTextFromNodeIfAvailable(Element doc) get Text From Node If Available StringBuffer result = new StringBuffer(); for (Node child : doc.childNodes()) { if (child instanceof TextNode) { result.append(((TextNode) child).text()); return result.toString(); |
String | getTextFromNodeSelect(Element doc, String location, String locationValue) get Text From Node Select String[] locations = location.split(","); Element element = doc.select(locations[0] + "[" + locations[1] + "=" + locationValue + "]").first(); String result = (element != null) ? element.text() : "none"; return result.trim(); |
Element | getTitle(Element el, String[] titles) get Title for (String title : titles) if (el.tagName().equals(title)) return el; Elements subsectionTitles = new Elements(); for (String title : titles) subsectionTitles.addAll(el.select(" " + title)); return subsectionTitles.get(0); |
String | getUserId(Element authorElement) get User Id String userIdUrL = authorElement.attr("href"); String userId = userIdUrL.substring(userIdUrL.indexOf("/citations?user=") + USER_URL_START_INDEX, userIdUrL.indexOf("/citations?user=") + USER_URL_END_INDEX); return userId; |
boolean | isChildOf(Element child, Elements possibleParents) Determines whether the given element is a child of one of the given parent elements. for (Element parent : child.parents()) { if (possibleParents.contains(parent)) { return true; return false; |