好诡异.....................试了很多次才弄好!!!!!!!!!!!!!import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.net.HttpURLConnection;import java.net.URL;public class test1 { public static void main(String[] a) throws IOException { String url = "http://video.shishicai.cn/haoma/gd11x5/list/2010-07-16.aspx";System.out.println(getHTML(url, "utf-8")); //使用原念信网页里声明的gb2312反而会慧高渣出现乱码前悄 } public static String getHTML(String pageURL, String encoding) { StringBuilder pageHTML = new StringBuilder(); try { URL url = new URL(pageURL); HttpURLConnection connection = (HttpURLConnection) url .openConnection(); connection.setRequestProperty("User-Agent", "MSIE 7.0"); BufferedReader br = new BufferedReader(new InputStreamReader( connection.getInputStream(), encoding)); String line = null; while ((line = br.readLine()) != null) { pageHTML.append(line); pageHTML.append("\r\n"); } connection.disconnect(); } catch (Exception e) { e.printStackTrace(); } return pageHTML.toString(); }}
相关文章
-
电脑网页打不开,显示此网站安全证书有问题,这怎么解决呢?
2023-08-15 03:51 阅读(631) -
JAVA通用版
2023-08-14 10:54 阅读(541) -
北京国泰中融没有网页客服的吗?这样的用户体验不太舒服呀!!
2023-08-13 21:24 阅读(619)
1 悍将传世网页版
554 阅读
2 自动弹出网页yue365
617 阅读
3 为什么网页总是弹出农牧场助手下载
563 阅读
4 网页上部分flash 不显示
610 阅读
5 从哪里java6.0下载
546 阅读