当前位置: 首页>>代码示例>>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;未经允许,请勿转载。