// 通过对应 的URL地址,读取页面里面的内容
public String getHtmlReadLine(String httpurl) throws Exception {
String CurrentLine = "";
String TotalString = "";
InputStream urlStream;
String content = "";
try {
URL url = new URL(httpurl);
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(
"cmproxy.gmcc.net", 8081));
HttpURLConnection connection = (HttpURLConnection) url
.openConnection(proxy);
// HttpURLConnection connection = (HttpURLConnection) url
// .openConnection();
connection.connect();
urlStream = connection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(
urlStream, "gbk"));
while ((CurrentLine = reader.readLine()) != null) {
TotalString += CurrentLine;
}
content = TotalString;
} catch (Exception e) {
throw e;
// e.printStackTrace();
}
return content;
}
通过对应 的URL地址,读取页面里面的内容
最新推荐文章于 2024-09-23 15:59:08 发布