rbingfeng 发表于 2013-2-7 15:11:00

获取网页html代码

获取网页html代码类
import java.net.*;import java.io.*;public class WebCode {public static void main(String args[]) throws Exception{    URL url=new URL("http://www.chinadaily.com.cn/enewsletter/headlinenews.html ");    URLConnection connection=url.openConnection();    InputStream in=connection.getInputStream();    ByteArrayOutputStream buffer=new ByteArrayOutputStream();    byte[] buff=new byte;    int len=-1;    while((len=in.read(buff))!=-1){      buffer.write(buff,0,len);    }    System.out.println(new String(buffer.toByteArray()));}}
页: [1]
查看完整版本: 获取网页html代码