当前位置: 首页>>代码示例>>Java>>正文


Java Element.children方法代码示例

本文整理汇总了Java中org.jsoup.nodes.Element.children方法的典型用法代码示例。如果您正苦于以下问题:Java Element.children方法的具体用法?Java Element.children怎么用?Java Element.children使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jsoup.nodes.Element的用法示例。


在下文中一共展示了Element.children方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseProxys

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public List<Proxy> parseProxys(String content) {
    Document doc = Jsoup.parse(content);
    Elements elements = doc.select("div#list table tbody tr");
    List<Proxy> proxyList = new ArrayList<>();
    for(Element tr : elements){
        Elements tds = tr.children();
        String ip = tds.get(0).text().trim();
        Integer port = Integer.parseInt(tds.get(1).text());
        proxyList.add(new Proxy(ip,port));
    }
    return proxyList;
}
 
开发者ID:StevenKin,项目名称:ZhihuQuestionsSpider,代码行数:14,代码来源:KuaidailiProxySite.java

示例2: GetDivContent

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private static String GetDivContent(Element div) {
    StringBuilder sb = new StringBuilder();
    //考虑div里标签内容的顺序,对div子树进行深度优先搜索
    Stack<Element> sk = new Stack<Element>();
    sk.push(div);
    while (!sk.empty()) {
        //
        Element e = sk.pop();
        //对于div中的div过滤掉
        if (e != div && e.tagName().equals("div")) continue;
        //考虑正文被包含在p标签中的情况,并且p标签里不能含有a标签
        if (e.tagName().equals("p") && e.getElementsByTag("a").size() == 0) {
            String className = e.className();
            if (className.length() != 0 && className.equals("pictext")) continue;
            sb.append(e.text());
            sb.append("\n");
            continue;
        } else if (e.tagName().equals("td")) {
            //考虑正文被包含在td标签中的情况
            if (e.getElementsByTag("div").size() != 0) continue;
            sb.append(e.text());
            sb.append("\n");
            continue;

        }
        //将孩子节点加入栈中
        Elements children = e.children();
        for (int i = children.size() - 1; i >= 0; i--) {
            sk.push((Element) children.get(i));
        }
    }

    return sb.toString();
}
 
开发者ID:xjtushilei,项目名称:ScriptSpider,代码行数:35,代码来源:ContentExtractor.java

示例3: doAnalysis

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public List doAnalysis(String html) {
	List<Major> list = new ArrayList<Major>();
	Element element = null;
	Elements options = null;
	element=HTMLUtil.getSelectorByName(html, Constants.HTML_ELEMENT_NAME.SELECT_NAME_MAJOR.getValue());
	if (element != null) {
		options = element.children();
		Major major = null;
		for (Element e : options) {
			if (e.val().equals("")||e.text()==null||e.text().trim().equals("")||e.val().equals("Nothing"))
				continue;
			major = new Major();
			major.setName(HTMLUtil.cutName(e.text()));
			major.setNo(e.attr("value"));
			Academy academy=new Academy();
			academy.setNo(academyNo);
			major.setAcademy(academy);
			list.add(major);
		}
	}
	return list;
}
 
开发者ID:liaojiacan,项目名称:zhkuas_ssm_maven,代码行数:24,代码来源:MajorAnalysiser.java

示例4: doAnalysis

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
	public List<Teacher> doAnalysis(String html) {
		List<Teacher> list = new ArrayList<Teacher>();
		Element element = null;
		Elements options = null;
		element=HTMLUtil.getSelectorByName(html, Constants.HTML_ELEMENT_NAME.SELECT_NAME_TEACHER.getValue());
		if (element != null) {
			options = element.children();
			Teacher teacher = null;
			for (Element e : options) {
				if (e.attr("value").equals(""))
					continue;
				teacher = new Teacher();
				teacher.setName(HTMLUtil.cutName(e.text()).trim());
				teacher.setNo(e.attr("value").trim());
//				teacher.setNameNo(HTMLUtil.cutNameNo(e.text()));
				list.add(teacher);
			}
		}

		return list;
	}
 
开发者ID:liaojiacan,项目名称:zhkuas_ssm_maven,代码行数:23,代码来源:TeacherAnalysiser.java

示例5: doAnalysis

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public List doAnalysis(String html) {
	List<KeyValue> list = new ArrayList<KeyValue>();
	Element element = null;
	Elements options = null;
	element=HTMLUtil.getSelectorByName(html,getSelecterName());
	if (element != null) {
		options = element.children();
		for (Element e : options) {
			if (e.val().equals("")||e.text().equals(""))
				continue;
			list.add(new KeyValue(e.val(),e.text()));
		}
	}
	return list;
}
 
开发者ID:liaojiacan,项目名称:zhkuas_ssm_maven,代码行数:17,代码来源:SelectorValueAnalysiser.java

示例6: doAnalysis

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public List doAnalysis(String html) {
	List<BaseClass> list = new ArrayList<BaseClass>();
	Element element = null;
	Elements options = null;
	element=HTMLUtil.getSelectorByName(html, Constants.HTML_ELEMENT_NAME.SELECT_NAME_BASECLASS.getValue());
	if (element != null) {
		options = element.children();
		BaseClass baseClass = null;
		for (Element e : options) {
			if (e.attr("value").equals("")||e.text()==null||e.text().equals(""))
				continue;
			baseClass = new BaseClass();
			baseClass.setName(HTMLUtil.cutName(e.text()));
			baseClass.setNo(e.attr("value"));
			baseClass.setGrade(getGrade());
			baseClass.setMajor(major);
			list.add(baseClass);
		}
	}
	return list;
}
 
开发者ID:liaojiacan,项目名称:zhkuas_ssm_maven,代码行数:23,代码来源:BaseClassAnalysiser.java

示例7: doAnalysis

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public List doAnalysis(String html) {
	List<Course> list = new ArrayList<Course>();
	Element element = null;
	Elements options = null;
	element=HTMLUtil.getSelectorByName(html, Constants.HTML_ELEMENT_NAME.SELECT_NAME_COURSE.getValue());
	if (element != null) {
		options = element.children();
		Course course = null;
		for (Element e : options) {
			if (e.attr("value").equals(""))
				continue;
			course = new Course();
			course.setName(HTMLUtil.cutName(e.text()));
			course.setNo(e.attr("value"));
			course.setNameNo(HTMLUtil.cutNameNo(e.text()));
			list.add(course);
		}
	}
	return list;
}
 
开发者ID:liaojiacan,项目名称:zhkuas_ssm_maven,代码行数:22,代码来源:CourseBasicalInfoAnalysiser.java

示例8: doAnalysis

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public List<Organization> doAnalysis(String html) {
		List<Organization> list = new ArrayList<Organization>();
		Element element = null;
		Elements options = null;
		element=HTMLUtil.getSelectorByName(html, Constants.HTML_ELEMENT_NAME.SELECT_NAME_ORGANIZATION.getValue());
		if (element != null) {
			options = element.children();
			Organization organization = null;
			for (Element e : options) {
				if (e.attr("value").equals(""))
					continue;
				organization = new Organization();
				organization.setName(HTMLUtil.cutName(e.text()));
				organization.setNo(e.attr("value"));
				if(organization.getName()!=null&&(organization.getName().indexOf("学院")<0&&organization.getName().indexOf("系")<0)){
					organization.setTypeId(Organization.TYPE_ORGANIZATION);
				}else{
					organization.setTypeId(Academy.TYPE_ACADMEY);
				}
				list.add(organization);
			}
		}
		return list;
}
 
开发者ID:liaojiacan,项目名称:zhkuas_ssm_maven,代码行数:26,代码来源:OrganizationAnalysiser.java

示例9: getRelatedVideos

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public StreamInfoItemCollector getRelatedVideos() throws IOException, ExtractionException {
    assertPageFetched();
    try {
        StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId());
        Element ul = doc.select("ul[id=\"watch-related\"]").first();
        if (ul != null) {
            for (Element li : ul.children()) {
                // first check if we have a playlist. If so leave them out
                if (li.select("a[class*=\"content-link\"]").first() != null) {
                    collector.commit(extractVideoPreviewInfo(li));
                }
            }
        }
        return collector;
    } catch (Exception e) {
        throw new ParsingException("Could not get related videos", e);
    }
}
 
开发者ID:TeamNewPipe,项目名称:NewPipeExtractor,代码行数:20,代码来源:YoutubeStreamExtractor.java

示例10: readStepButtons

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private void readStepButtons(Elements elements) {
  Elements buttonsElements = elements.select(DESIGN_TAG_BUTTONS);
  if (!buttonsElements.isEmpty()) {
    Element buttonsElement = buttonsElements.get(0);
    Elements children = buttonsElement.children();

    if (children.size() > 4) {
      String msg = "A maximum of 4 children allowed for tag <" + DESIGN_TAG_BUTTONS + ">";
      throw new IllegalArgumentException(msg);
    }

    List<StepAction> stepActions = new ArrayList<>();
    for (Element buttonElement : children) {
      StepAction stepAction = readStepButton(buttonElement);
      if (stepActions.contains(stepAction)) {
        throw new IllegalArgumentException("Duplicate step action found: " + stepAction);
      }
      stepActions.add(stepAction);
    }
  }
}
 
开发者ID:Juchar,项目名称:md-stepper,代码行数:22,代码来源:Step.java

示例11: readDesign

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public void readDesign(Element design, DesignContext designContext) {
  super.readDesign(design, designContext);

  for (Element child : design.children()) {
    Component childComponent = designContext.readDesign(child);
    if (!(childComponent instanceof Step)) {
      throw new IllegalArgumentException("Only implementations of " + Step.class.getName() +
                                         " are allowed as children of " + getClass().getName());
    }

    stepIterator.add(((Step) childComponent));
  }

  boolean linear = false;

  Attributes attributes = design.attributes();
  if (attributes.hasKey(DESIGN_ATTRIBUTE_LINEAR)) {
    linear = DesignAttributeHandler.getFormatter()
                                   .parse(design.attr(DESIGN_ATTRIBUTE_LINEAR), Boolean.class);
  }

  stepIterator.setLinear(linear);
}
 
开发者ID:Juchar,项目名称:md-stepper,代码行数:25,代码来源:AbstractStepper.java

示例12: 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;
            }
        }
    }
}
 
开发者ID:TheAndroidMaster,项目名称:Blackboard,代码行数:25,代码来源:HtmlUtils.java

示例13: syncStockInfos

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@PostMapping("/stock-infos/sync")
@ResponseStatus(HttpStatus.OK)
public void syncStockInfos() throws IOException {
	Document doc = Jsoup.connect(ConfigConstant.STOCK_INFO_URL).get();
	Element element = doc.getElementById("quotesearch");
	Elements ulElements = element.select("ul");
	for (Element ulElement : ulElements) {
		Elements liElements = ulElement.select("li");
		for (Element liElement : liElements) {
			Elements children = liElement.children();
			if (!children.isEmpty()) {
				String stockInfo = children.get(0).text();
				if (ObjectUtils.isNotEmpty(stockInfo)) {
					stockInfo = stockInfo.substring(0, stockInfo.length() - 1);
					String[] stockInfos = stockInfo.split("\\(");
					String stockName = stockInfos[0];
					String stockCode = stockInfos[1];
					if (stockCode.startsWith(ConfigConstant.SH_STOCK_PRE)) {
						saveStockInfo(stockCode, stockName, ConfigConstant.STOCK_TYPE_SH);
					} else if (stockCode.startsWith(ConfigConstant.SZ_STOCK_PRE)) {
						saveStockInfo(stockCode, stockName, ConfigConstant.STOCK_TYPE_SZ);
					} else if (stockCode.startsWith(ConfigConstant.CY_STOCK_PRE)) {
						saveStockInfo(stockCode, stockName, ConfigConstant.STOCK_TYPE_SZ);
					}
				}
			}
		}
	}
}
 
开发者ID:wengwh,项目名称:plumdo-stock,代码行数:30,代码来源:StockInfoSyncResource.java

示例14: readStepContent

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private void readStepContent(Elements elements) {
  Elements contentElements = elements.select(DESIGN_TAG_CONTENT);
  if (!contentElements.isEmpty()) {
    Element contentElement = contentElements.get(0);
    Elements children = contentElement.children();

    if (children.size() > 1) {
      String msg = "Only one child allowed for tag <" + DESIGN_TAG_CONTENT + ">";
      throw new IllegalArgumentException(msg);
    }

    Component component = designContext.readDesign(children.first());
    setContent(component);
  }
}
 
开发者ID:Juchar,项目名称:md-stepper,代码行数:16,代码来源:Step.java

示例15: printNode

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private static String printNode(Element root, int indentation) {
    StringBuilder sb = new StringBuilder(indentation);
    for (int i = 0; i < indentation; i++) {
        sb.append(' ');
    }
    sb.append(root.tagName());
    sb.append(':');
    sb.append(root.ownText());
    sb.append('\n');
    for (Element el : root.children()) {
        sb.append(printNode(el, indentation + 1));
        sb.append('\n');
    }
    return sb.toString();
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:16,代码来源:SHelper.java


注:本文中的org.jsoup.nodes.Element.children方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。