package com.gethtmlContent; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class getHtmlContent { public static void main(String[] args) { System.getProperties().put("http.proxyHost", "xx.xx.xx.xx");// 代理服务器IP地址 System.getProperties().put("http.proxyPort", "xxxx");// 代理服务器端口 String url = "xxxxx"; System.out.println(getHtmlConentByUrl(url)); } public static String getHtmlConentByUrl(String ssourl) { try { URL url = new URL(ssourl); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setInstanceFollowRedirects(false); con.setUseCaches(false); con.setAllowUserInteraction(false); con.connect(); StringBuffer sb = new StringBuffer(); String line = ""; BufferedReader URLinput = new BufferedReader(new InputStreamReader(con.getInputStream())); while ((line = URLinput.readLine()) != null) { sb.append(line); } con.disconnect(); return sb.toString().toLowerCase(); } catch (Exception e) { return null; } } }