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


Java Document.toString方法代码示例

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


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

示例1: createApplication

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
/**
 * Create a new OVH Application using https://eu.api.ovh.com/createApp/
 * Outout the Application Key and Application Secret in std-out
 * @param nic
 * @param password
 * @throws IOException
 */
public void createApplication(String nic, String password) throws IOException {
	String url = "https://eu.api.ovh.com/createApp/";
	Document doc = Jsoup.connect(url)
			.data("nic", nic)
			.data("password", password)
			.data("applicationName", "One Shoot Token")
			.data("applicationDescription", "One Shoot Token")
			.post();
	String body = doc.toString();
	Pattern extract = Pattern.compile(" Application (\\w+)<pre><name>([^<]+)</name></pre>");
	Matcher m = extract.matcher(body);
	String Key = null;
	String Secret = null;
	while (m.find()) {
		String k = m.group(1);
		String v = m.group(2);
		if (k.equals("Key"))
			Key = v;
		if (k.equals("Secret"))
			Secret = v;
	}
	log.warn("Key:{} Secret:{}", Key, Secret);
}
 
开发者ID:UrielCh,项目名称:ovh-java-sdk,代码行数:31,代码来源:ApiOvhUtils.java

示例2: getPhotoIDsToURLs

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
private Map<String,String> getPhotoIDsToURLs(String photoID) throws IOException {
    Map<String,String> photoIDsToURLs = new HashMap<>();
    Map<String,String> postData = new HashMap<>();
    // act=show&al=1&list=album45506334_172415053&module=photos&photo=45506334_304658196
    postData.put("list", getGID(this.url));
    postData.put("act", "show");
    postData.put("al", "1");
    postData.put("module", "photos");
    postData.put("photo", photoID);
    Document doc = Jsoup
            .connect("https://vk.com/al_photos.php")
            .header("Referer", this.url.toExternalForm())
            .ignoreContentType(true)
            .userAgent(USER_AGENT)
            .timeout(5000)
            .data(postData)
            .post();
    String jsonString = doc.toString();
    jsonString = jsonString.substring(jsonString.indexOf("<!json>") + "<!json>".length());
    jsonString = jsonString.substring(0, jsonString.indexOf("<!>"));
    JSONArray json = new JSONArray(jsonString);
    for (int i = 0; i < json.length(); i++) {
        JSONObject jsonImage = json.getJSONObject(i);
        for (String key : new String[] {"z_src", "y_src", "x_src"}) {
            if (!jsonImage.has(key)) {
                continue;
            }
            photoIDsToURLs.put(jsonImage.getString("id"), jsonImage.getString(key));
            break;
        }
    }
    return photoIDsToURLs;
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:34,代码来源:VkRipper.java

示例3: absPath

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
private String absPath(String input, String baseUrl) {
    Document doc = Jsoup.parse(input);
    //doc.getAllElements();
    //doc.head().prepend("<base href=" + baseUrl +"> </base>");
    Elements link = doc.select("link");
    link.attr("href", baseUrl + "/" + link.attr("href"));

    return doc.toString();
}
 
开发者ID:jsparber,项目名称:CaptivePortalAutologin,代码行数:10,代码来源:HttpServer.java

示例4: getHtmlPageJsoup

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
/**
 * Jsoup을 이용한 HTML 코드 파싱.
 * @param eachArchiveAddress 실제 만화가 담긴 아카이브 주소
 * @return 성공하면 html 코드를 리턴
 */
private String getHtmlPageJsoup(String eachArchiveAddress) throws Exception {
	System.out.print("고속 연결 시도중 ... ");

	// pageSource = Html코드를 포함한 페이지 소스코드가 담길 스트링, domain = http://wasabisyrup.com <-마지막 / 안붙음!
	String pageSource = null;
	
	// POST방식으로 아예 처음부터 비밀번호를 body에 담아 전달
	Response response = Jsoup.connect(eachArchiveAddress)
		.userAgent(UserAgent.getUserAgent())
		.header("charset", "utf-8")
		.header("Accept-Encoding", "gzip") //20171126 gzip 추가
		.data("pass", PASSWORD)
		.followRedirects(true)
		.execute();
	
	Document preDoc = response.parse(); //받아온 HTML 코드를 저장
		
	// <div class="gallery-template">이 만화 담긴 곳.
	if(preDoc.select("div.gallery-template").isEmpty()) {
		throw new Exception("Jsoup Parsing Failed");
	}
	else { // 만약 Jsoup 파싱 시 내용 있으면 성공
		pageSource = preDoc.toString();
	}

	System.out.println("성공");
	return pageSource; //성공 시 html코드 리턴
}
 
开发者ID:occidere,项目名称:MMDownloader,代码行数:34,代码来源:Downloader.java

示例5: addErrorActivation

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
public static String addErrorActivation(String filePath) {
	Document doc = readHtmlFile(filePath);
	StringBuilder sb = new StringBuilder();
	sb.append("<script>");
	sb.append("window.onload = function () {swal({title: '账户激活失败!',text: '请联系客户!',type: 'error',confirmButtonText: '确定'});}");
	sb.append("</script>");
	doc.body().prepend(sb.toString());
	return doc.toString();
}
 
开发者ID:iunet,项目名称:iunet-blog,代码行数:10,代码来源:HtmlUtil.java

示例6: addErrorActivation2

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
public static String addErrorActivation2(String filePath) {
	Document doc = readHtmlFile(filePath);
	StringBuilder sb = new StringBuilder();
	sb.append("<script>");
	sb.append("window.onload = function () {swal({title: '系统错误',text: '您已激活或尚未注册',type: 'error',confirmButtonText: '确定'}, function () {window.top.location.href = '/"+webContext+"'});}");
	sb.append("</script>");
	doc.body().prepend(sb.toString());
	return doc.toString();
}
 
开发者ID:iunet,项目名称:iunet-blog,代码行数:10,代码来源:HtmlUtil.java

示例7: addSuccessActivation

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
public static String addSuccessActivation(String filePath) {
	Document doc = readHtmlFile(filePath);
	StringBuilder sb = new StringBuilder();
	sb.append("<script>");
	sb.append("window.onload = function () {swal({title: '账户激活成功!',text: '',type: 'success',confirmButtonText: '确定'}, function () {window.top.location.href = '/"+webContext+"'});}");
	sb.append("</script>");
	doc.body().prepend(sb.toString());
	return doc.toString();
}
 
开发者ID:iunet,项目名称:iunet-blog,代码行数:10,代码来源:HtmlUtil.java

示例8: doGetHtml

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
public final String doGetHtml(String url, String userAgent, boolean getBody) {
    try {
        Document document = Jsoup.connect(url).timeout(CONNECT_TIMEOUT)
                .userAgent(userAgent)
                .get();
        if (getBody) {
            return document.body().toString();
        }
        return document.toString();
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:shenhuanet,项目名称:ZhidaoDaily-android,代码行数:15,代码来源:BaseHttpApi.java

示例9: processCDN

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
public static String processCDN(String content) {
    if (StringUtils.isBlank(content)) {
        return content;
    }


    Document doc = Jsoup.parse(content);

    Elements jsElements = doc.select("script[src]");
    replace(jsElements, "src");

    Elements imgElements = doc.select("img[src]");
    replace(imgElements, "src");

    Elements lazyElements = doc.select("img[data-original]");
    replace(lazyElements, "data-original");

    Elements linkElements = doc.select("link[href]");
    replace(linkElements, "href");

    return doc.toString();

}
 
开发者ID:yangfuhai,项目名称:jboot,代码行数:24,代码来源:RenderHelpler.java

示例10: Pagina

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
Pagina(Document html) {
    this.html = html.toString();
    document = Jsoup.parse(this.html);
}
 
开发者ID:GuilhermeShinti,项目名称:UnicesuLabs,代码行数:5,代码来源:Pagina.java

示例11: getContent

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
private String getContent() {
    Document doc = Jsoup.parse(getIntent("content"));
    Element imageElement = doc.select("img").first();
    if (imageElement != null) imageElement.remove();
    return "<div>" + doc.toString() + "</div>";
}
 
开发者ID:daeng-id,项目名称:nfkita-mobile,代码行数:7,代码来源:ReadArticleActivity.java


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