當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。