JAVA 获取网页流

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;
}
} }
上一篇:【Python撩妹合集】微信聊天机器人,推送天气早报、睡前故事、精美图片分享


下一篇:Linux之netstat命令详解