use of org.jsoup.nodes.Element in project nixmash-blog by mintster.
the class JsoupUI method displayImports.
// endregion
// region non-used demos
private void displayImports() {
Elements imports = doc.select("link[href]");
print("\nImports: (%d)", imports.size());
for (Element link : imports) {
print(" * %s <%s> (%s)", link.tagName(), link.attr("abs:href"), link.attr("rel"));
}
}
use of org.jsoup.nodes.Element in project nixmash-blog by mintster.
the class JsoupUI method getImages.
private List<JsoupImage> getImages(Document doc) {
List<JsoupImage> images = new ArrayList<>();
Elements elements;
elements = doc.select("[src]");
for (Element media : elements) {
if (media.tagName().equals("img")) {
JsoupImage img = new JsoupImage();
img.setSrc(media.attr("abs:src"));
img.setAlt(trim(media.attr("alt"), 60));
img.setHeight(attrIntToNull(media.attr("height")));
img.setWidth(attrIntToNull(media.attr("width")));
images.add(img);
}
}
return images;
}
use of org.jsoup.nodes.Element in project nixmash-blog by mintster.
the class JsoupUI method displayLInks.
private void displayLInks() {
Elements links = doc.select("a[href]");
print("\nLinks: (%d)", links.size());
for (Element link : links) {
print(" * a: <%s> (%s)", link.attr("abs:href"), trim(link.text(), 35));
}
}
use of org.jsoup.nodes.Element in project nixmash-blog by mintster.
the class JsoupHtmlParser method parseMultipleLinks.
private List<JsoupLink> parseMultipleLinks(Field f) {
List<JsoupLink> links = new ArrayList<>();
Elements section;
Elements elements;
String css = f.getAnnotation(LinkSelector.class).value();
if (css.length() > 0) {
section = doc.select(css);
if (section == null)
return null;
elements = section.first().select("a[href]");
} else {
elements = doc.select("a[href]");
}
for (Element element : elements) {
if (element.tagName().equals("a")) {
links.add(createJsoupLink(element));
}
}
return links;
}
use of org.jsoup.nodes.Element in project nixmash-blog by mintster.
the class JsoupHtmlParser method twitterContent.
private String twitterContent(String tagName) {
String selector = String.format("meta[name=twitter:%s]", tagName);
String content = null;
Element element = doc.select(selector).first();
if (element != null) {
content = element.attr("content");
}
return content;
}
Aggregations