本文整理汇总了Java中org.jsoup.nodes.Element.parent方法的典型用法代码示例。如果您正苦于以下问题:Java Element.parent方法的具体用法?Java Element.parent怎么用?Java Element.parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jsoup.nodes.Element
的用法示例。
在下文中一共展示了Element.parent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getURLsFromPage
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public List<String> getURLsFromPage(Document page) {
List<String> imageURLs = new ArrayList<>();
// Page contains images
logger.info("Look for images.");
for (Element thumb : page.select("img")) {
logger.info("Img");
if (super.isStopped()) break;
// Find thumbnail image source
String image = null;
String img_type = null;
String src = null;
if (thumb.hasAttr("typeof")) {
img_type = thumb.attr("typeof");
if (img_type.equals("foaf:Image")) {
logger.debug("Found image with " + img_type);
if (thumb.parent() != null &&
thumb.parent().parent() != null &&
thumb.parent().parent().attr("class") != null &&
thumb.parent().parent().attr("class").equals("aimage-center")
)
{
src = thumb.attr("src");
logger.debug("Found url with " + src);
if (!src.contains("zizki.com")) {
} else {
imageURLs.add(src.replace("/styles/medium/public/","/styles/large/public/"));
}
}
}
}
}
return imageURLs;
}
示例2: removeUselessElements
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private static void removeUselessElements(Element element) {
for (Element child : element.children()) {
if (child.children().size() > 0)
removeUselessElements(child);
else {
switch (child.tagName()) {
case "br":
case "a":
case "p":
case "h1":
case "h2":
case "h3":
case "h4":
case "span":
break;
default:
Element parent = child.parent();
child.remove();
parent.insertChildren(0, child.children());
break;
}
}
}
}
示例3: matches
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
public boolean matches(Element root, Element element) {
if (root == element)
return false;
Element parent = element.parent();
while (true) {
if (evaluator.matches(root, parent))
return true;
if (parent == root)
break;
parent = parent.parent();
}
return false;
}
示例4: call
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public Object call(Element element, List<SyntaxNode> params) {
int index = 1;
Integer integer = XpathUtil.firstParamToInt(params, element, getName());
if (integer != null) {
index = integer;
}
for (int i = 0; i < index; i++) {
element = element.parent();
}
return element;
}
示例5: append
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private int append(Element node, StringBuilder sb, String tagName) {
int countOfP = 0; // Number of P elements in the article
int paragraphWithTextIndex = 0;
// is select more costly then getElementsByTag?
MAIN:
for (Element e : node.select(tagName)) {
Element tmpEl = e;
// check all elements until 'node'
while (tmpEl != null && !tmpEl.equals(node)) {
if (unlikely(tmpEl))
continue MAIN;
tmpEl = tmpEl.parent();
}
String text = node2Text(e);
if (text.isEmpty() || text.length() < getMinParagraph(paragraphWithTextIndex)
|| text.length() > SHelper.countLetters(text) * 2) {
continue;
}
if (e.tagName().equals("p")) {
countOfP++;
}
sb.append(text);
sb.append("\n\n");
paragraphWithTextIndex += 1;
}
return countOfP;
}
示例6: call
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public Elements call(Element e, List<String> args) {
return new Elements(e.parent());
}
示例7: root
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
public static Element root(Element el) {
while (el.parent() == null) {
el = el.parent();
}
return el;
}
示例8: parent
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
/**
* 父节点
* @param e
* @return
*/
public Elements parent(Element e){
return new Elements(e.parent());
}