使用httpclient4.3.4版本
/**
* 得到网页源码*
* @param response 响应
* @param charset 编码
* @return
* @throws IOException
*/
public static String getHtml(CloseableHttpResponse response, String charset)
throws IOException {
String html = null;
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream inputStream = entity.getContent();
html = IOUtils.toString(inputStream, charset);//使用Apache的commons-io-2.4.jar
}
return html;
}