发送Http请求获取网页源码

来源:互联网 发布:淘宝联盟官网登录入口 编辑:程序博客网 时间:2024/06/07 15:03

StringBuilder temp = new StringBuilder();

URL url = new URL(http://tech.163.com/special/000915BE/yys3g.html);

HttpURLConnection urlcon = (HttpURLConnection) url.openConnection();

InputStream in = urlcon.getInputStream();

BufferedReader rd = new BufferedReader(new InputStreamReader(in));

while (rd.read() != -1) {

temp.append(rd.readLine()+"\r");

 

}

System.out.println(temp.toString());

原创粉丝点击