Here you can find the source of getDocument(CloseableHttpClient client, String url)
Parameter | Description |
---|
public static Document getDocument(CloseableHttpClient client, String url) throws ClientProtocolException, IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import org.apache.http.HttpEntity; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.util.EntityUtils; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; public class Main { public static Document getDocument(CloseableHttpClient client, String url) throws ClientProtocolException, IOException { return Jsoup.parse(getString(client, url)); }// www . j av a 2s. c o m public static String getString(CloseableHttpClient client, String url) throws ClientProtocolException, IOException { HttpGet getPage = new HttpGet(url); String htmlContent = null; CloseableHttpResponse response = client.execute(getPage); try { HttpEntity entity = response.getEntity(); htmlContent = EntityUtils.toString(entity); } finally { response.close(); } return htmlContent; } }