package test;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
public class TestURLReader {
/**
* @param args
*/
public static void main(String[] args) {
try {
URL url = new URL("http://www.baidu.com");
BufferedReader buf = new BufferedReader(new InputStreamReader(url
.openStream(), "GBK"));
String str;
while( ( str = buf.readLine() ) != null ){
System.out.println(str);
}
} catch (Exception e1) {
e1.printStackTrace();
} finally {
System.exit(0);
}
}
}
咋取baidu首页的内容?或其他链接的html
最新推荐文章于 2021-10-20 13:53:13 发布