當前位置: 首頁>>代碼示例>>Java>>正文


Java Element.outerHtml方法代碼示例

本文整理匯總了Java中org.jsoup.nodes.Element.outerHtml方法的典型用法代碼示例。如果您正苦於以下問題:Java Element.outerHtml方法的具體用法?Java Element.outerHtml怎麽用?Java Element.outerHtml使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jsoup.nodes.Element的用法示例。


在下文中一共展示了Element.outerHtml方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parseAlbumData

import org.jsoup.nodes.Element; //導入方法依賴的package包/類
public static Map<String, Object> parseAlbumData(String albumURL) throws Exception
{
	Map<String, Object> albumMap = new HashMap<String, Object>();
	Elements scriptTags = HttpUtil.getScriptList(albumURL);
	for(Element element : scriptTags)
	{
		String text = element.outerHtml();
		if(StringUtils.containsIgnoreCase(text, "var TralbumData"))
		{
			String albumData = extractJson(text, "var TralbumData =", "};",false) + "};";
			if(StringUtils.isNotBlank(albumData))
			{
				Map<String, String> jsonMap = getJsonMap(albumData);
				JsonObject albumJsonObject =  new JsonParser().parse(jsonMap.get("current")).getAsJsonObject();
				List<JsonObject> trackList = getTrackInfo(jsonMap.get("trackinfo"));
				albumMap.put("albumMetadata", albumJsonObject);
				albumMap.put("trackMetadata", trackList);
				return albumMap;
			}
		}
	}
	return null;
}
 
開發者ID:scriptkittie,項目名稱:bandcamp-api,代碼行數:24,代碼來源:JSONUtil.java

示例2: extractDataWithJsoup

import org.jsoup.nodes.Element; //導入方法依賴的package包/類
public void extractDataWithJsoup(String href){
	Document doc = null;
	try {
		doc = Jsoup.connect(href).timeout(10*1000).userAgent("Mozilla").ignoreHttpErrors(true).get();
	} catch (IOException e) {
		//Your exception handling here
	}
	if(doc != null){
		String title = doc.title();
		String text = doc.body().text();
		Elements links = doc.select("a[href]");
		for (Element link : links) {
			String linkHref = link.attr("href");
			String linkText = link.text();
			String linkOuterHtml = link.outerHtml(); 
			String linkInnerHtml = link.html();
		}
	}
}
 
開發者ID:PacktPublishing,項目名稱:Java-Data-Science-Cookbook,代碼行數:20,代碼來源:JsoupTesting.java

示例3: parseForContent

import org.jsoup.nodes.Element; //導入方法依賴的package包/類
public static String parseForContent(String key, Element seItemBody) {
    String content = seItemBody.outerHtml();

    // check if key is found and remove everything in front
    int keyOccurrence = content.toLowerCase().indexOf(key);
    if (keyOccurrence == -1) {
        return "";
    } else {
        content = content.substring(keyOccurrence + key.length());
    }

    // check if line break is found and remove everything in front
    // assumption: content is right after the key and on new line
    int firstLineBreak = content.indexOf("<br>");
    if (firstLineBreak == -1) {
        return "";
    } else {
        content = content.substring(firstLineBreak + 4);
    }
    content = content.replaceAll("\r", "");
    content = content.replaceAll("\n", "");

    // only read until the next line break
    Pattern patternLineBreak = Pattern.compile("(.+?)<br>.*");
    Matcher matcherLineBreak = patternLineBreak.matcher(content);
    // if no line break tag is found just read until the next html tag occurs
    Pattern patternTag = Pattern.compile("(.+?)<.*>.*");
    Matcher matcherTag = patternTag.matcher(content);

    if (matcherLineBreak.find()) {
        content = matcherLineBreak.group(1);
    } else if (matcherTag.find()) {
        content = matcherTag.group(1);
    } else {
        LOG.debug("No end html tag for key '{}' in [{}] parsed from [{}]", key, content, seItemBody.outerHtml());
    }

    content = content.trim();
    return content;
}
 
開發者ID:adr,項目名稱:eadlsync,代碼行數:41,代碼來源:SeItemContentParser.java

示例4: getValue

import org.jsoup.nodes.Element; //導入方法依賴的package包/類
private String getValue(Element element) {
    if (attrName == null) {
        return element.outerHtml();
    } else if ("innerHtml".equalsIgnoreCase(attrName)) {
        return element.html();
    } else if ("text".equalsIgnoreCase(attrName)) {
        return getText(element);
    } else if ("allText".equalsIgnoreCase(attrName)) {
        return element.text();
    } else {
        return element.attr(attrName);
    }
}
 
開發者ID:fengzhizi715,項目名稱:NetDiscovery,代碼行數:14,代碼來源:CssSelector.java

示例5: getValue

import org.jsoup.nodes.Element; //導入方法依賴的package包/類
private <U> String getValue(Element node, Class<U> clazz) {
    if (node == null) {
        return defValue;
    }
    String value;
    switch (attribute) {
        case "":
            value = node.text();
            break;
        case "html":
        case "innerHtml":
            value = node.html();
            break;
        case "outerHtml":
            value = node.outerHtml();
            break;
        default:
            value = node.attr(attribute);
            break;
    }
    if (!clazz.equals(Date.class)
            && !clazz.equals(BigDecimal.class)
            && !format.equals(Selector.NO_VALUE)) {
        Pattern pattern = Pattern.compile(format);
        Matcher matcher = pattern.matcher(value);
        boolean found = matcher.find();
        if (found) {
            value = matcher.group(1);
            if (value.isEmpty()) {
                value = defValue;
            }
        }
    }
    return value;
}
 
開發者ID:DroidsOnRoids,項目名稱:jspoon,代碼行數:36,代碼來源:HtmlField.java

示例6: getValue

import org.jsoup.nodes.Element; //導入方法依賴的package包/類
private String getValue(Element element, String attrName) {
	if (attrName == null) {
		return element.outerHtml();
	} else if ("innerHtml".equalsIgnoreCase(attrName)) {
		return element.html();
	} else if ("text".equalsIgnoreCase(attrName)) {
		return getText(element);
	} else if ("allText".equalsIgnoreCase(attrName)) {
		return element.text();
	} else {
		return element.attr(attrName);
	}
}
 
開發者ID:xbynet,項目名稱:crawler,代碼行數:14,代碼來源:JsoupParser.java


注:本文中的org.jsoup.nodes.Element.outerHtml方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。