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


Java Element.childNodeSize方法代码示例

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


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

示例1: extractContent

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private String extractContent(String url) {
    String summary = "";
    try {
        Document doc = Jsoup.connect(url).get();
        Element element = doc.getElementById("intro").child(1);
        if (element.childNodeSize() == 2) {
            Element target = element.getElementsByClass("hidden").get(0);
            summary = target.text();
        } else {
            summary = element.text();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return summary;
}
 
开发者ID:Mindjet,项目名称:LiteReader,代码行数:17,代码来源:StaffDetailSummaryViewModel.java

示例2: getStringResNameAndValueMap

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
/**
 * 获取strings.xml 资源名-值 映射表
 *
 * @return
 */
protected Map<String, String> getStringResNameAndValueMap() {
    Map<String, String> map = new HashMap<>();

    Document document = getValuesXmlDocument();
    Elements strings  = document.getElementsByTag("string");

    for (int i = 0; i < strings.size(); i++) {
        Element element = strings.get(i);
        String  name    = element.attr("name");

        if (element.childNodeSize() > 0 && element.childNode(0) instanceof TextNode) {
            String text = ((TextNode) element.childNode(0)).text();

            map.put(name, text);
        }
    }

    return map;
}
 
开发者ID:kkmike999,项目名称:YuiHatano,代码行数:25,代码来源:ShadowResources.java

示例3: print2

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private void print2(String baseLocation) throws IOException, TransformerException, ParserConfigurationException {
        Document document = Jsoup.connect(baseLocation).get();
        Elements content = document.getElementsByAttributeValue("class", "entry-content");
        String title = null;
        ArrayList<String> list = new ArrayList<>();
        for (Element div : content) {
            List<Node> nodes = div.childNodes();
            for (Node node : nodes) {
                if (node instanceof Element) {
                    if (((Element) node).tagName().equals("h3")) {
                        writeFile(title, list);
                        list.clear();
                        System.out.println("Title: " + node.childNode(0));
                        title = node.childNode(0).toString();
                    } else if (((Element) node).tagName().equals("table")) {
                        //print table
                        Elements tr = ((Element) node).getElementsByTag("tr");
                        for (Element element : tr) {
                            Elements td = element.getElementsByTag("td");
                            for (Element value : td) {
                                if (value.childNodeSize() > 0) {
                                    if (!(value.childNode(0) instanceof Comment)) {
//                                        System.out.println("Emoticon: " + value.childNode(0) + " " + value.childNode(0).getClass().getSimpleName());
                                        list.add(value.childNode(0).toString());
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
 
开发者ID:tranleduy2000,项目名称:ascii_generate,代码行数:34,代码来源:GetEmoticons.java

示例4: QuakeInfo

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
public QuakeInfo(final Document doc) {
	this.url = "https://typhoon.yahoo.co.jp"+Optional.ofNullable(doc.getElementById("history")).map(history -> history.getElementsByTag("tr").get(1).getElementsByTag("td").first().getElementsByTag("a").first().attr("href")).orElse("");
	this.imageUrl = Optional.ofNullable(doc.getElementById("yjw_keihou").getElementsByTag("img").first()).map(image -> StringUtils.substringBefore(image.attr("src"), "?"));
	final Element info = doc.getElementById("eqinfdtl");
	final Map<String, String> data = info.getElementsByTag("table").get(0).getElementsByTag("tr").stream()
			.map(tr -> tr.getElementsByTag("td")).collect(Collectors.toMap(td -> td.get(0).text(), td -> td.get(1).text()));

	try {
		this.announceTime = FORMAT.parse(data.get("情報発表時刻"));
		final String quakeTime = data.get("発生時刻");
		this.quakeTime = FORMAT.parse(StringUtils.substring(quakeTime, 0, quakeTime.length()-2));
		this.epicenter = data.get("震源地");
		this.lat = data.get("緯度");
		this.lon = data.get("経度");
		this.depth = data.get("深さ");
		this.magnitude = NumberUtils.toFloat(data.get("マグニチュード"), -1f);
		this.info = data.get("情報");
	} catch (final ParseException e) {
		throw new RuntimeException("Parse Error", e);
	}

	final Element yjw = info.getElementsByTag("table").get(1);
	if (yjw.childNodeSize()<=1)
		this.maxIntensity = Optional.empty();
	else
		this.maxIntensity = SeismicIntensity.get(yjw.getElementsByTag("td").first().getElementsByTag("td").first().text());

	final Map<String, PrefectureDetail> details = new HashMap<>();
	yjw.getElementsByTag("tr").stream().filter(tr -> tr.attr("valign").equals("middle")).forEach(tr -> {
		final Optional<SeismicIntensity> intensity = SeismicIntensity.get(tr.getElementsByTag("td").first().getElementsByTag("td").first().text());
		tr.getElementsByTag("table").first().getElementsByTag("tr").stream().map(line -> line.getElementsByTag("td")).collect(Collectors.toMap(td -> td.get(0).text(), td -> td.get(1).text())).entrySet().forEach(entry -> {
			final String prefecture = entry.getKey();
			final PrefectureDetail detail = details.computeIfAbsent(prefecture, key -> new PrefectureDetail(prefecture));
			intensity.ifPresent(line -> Stream.of(StringUtils.split(entry.getValue(), " ")).forEach(str -> detail.addCity(line, str)));
		});
	});

	this.details = new ArrayList<>(details.values());
	Collections.sort(this.details, Comparator.reverseOrder());
}
 
开发者ID:Team-Fruit,项目名称:EEWBot,代码行数:41,代码来源:QuakeInfo.java


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