网页抓取

来源:百度知道 编辑:UC知道 时间:2024/05/15 03:44:12
我想要抓取百度搜索完后的(百度一下,找到相关网页约209,000篇,用时0.001秒)中的209000这个数据然后放到自己数据库中 应该怎么弄啊求教各位高手

URL url = new URL(
"http://www.baidu.com/s?wd=
+ 要的搜词,要编码后);
URLConnection conn = url.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(
is, "GBK"));
String line;

while ((line = br.readLine()) != null) {
//自己过滤取得
}