我的第一个简单的爬虫程序
2016-01-16 00:16
204 查看
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
/*
*获取百度首页的源代码
*/public class firstCrawl{
public static void main(String [] args){
URL url=new URL("www.baidu.com");
HttpConnection conn=url.openConnection();
BufferedReader br=new BufferedReader(new InputStreamReader(conn.getInputStream(),"gb2312"));
String line;
while((line=br.readLine)!=null){
System.out.println(line);
}
}
}
import java.net.HttpURLConnection;
import java.net.URL;
/*
*获取百度首页的源代码
*/public class firstCrawl{
public static void main(String [] args){
URL url=new URL("www.baidu.com");
HttpConnection conn=url.openConnection();
BufferedReader br=new BufferedReader(new InputStreamReader(conn.getInputStream(),"gb2312"));
String line;
while((line=br.readLine)!=null){
System.out.println(line);
}
}
}
相关文章推荐
- CSS中常用的清除浮动(闭合浮动)的方法
- Java面试题集(181-185)
- Cannot change version of project facet Dynamic Web Module to 2.5.
- 让TextView里面的文字逐个显示的动画效果实现(1)
- POJ 3159 Candies
- JavaScript基本用法
- Java面试题集(151-180)
- [MySQL]调整MySQL参数提高写入速度
- 【数组】Best Time to Buy and Sell Stock I/II
- 第三天笔记,今天听的有点晕,幸好公司年会,我们放3天假,所以慢慢复习吧
- NPOI.dll学习
- php加密解密函数
- 斐波那契数列
- Java面试题集(136-150)
- Java面试题集(116-135)
- Qwt中坐标轴的设置
- 【KMP+矩阵加速】BZOJ1009[HNOI2008]GT考试
- 字符串与数字转换-C语言
- Java面试题集(86-115)
- Android经典文章收藏笔记3