抓取网页信息的小程序怎么实现? 写一个小程序,可以输入网站地址,然后就抓取网站的html,用来监控网站是否正常运行,抓取到表明网站正常运行,抓取不到表明网站挂网了,并弹出抓取不到提示框.这样的程序怎么实现呢??求大神指点。我是菜鸟,才刚学JAVA。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 URLConnection conn = new URL("http://www.baidu.com").openConnection(); InputStream is = conn.getInputStream(); OutputStream os = new FileOutputStream("c:/save.html"); byte[] buffer = new byte[2048]; int length = 0; while(-1 != (length = is.read(buffer, 0, buffer.length))) { os.write(buffer, 0, length); } is.close(); os.close(); 1的代码放在main方法里面,会生成c:/save.html隔一段时间让程序运行一次用Timer & TimerTask, LZ百度吧.http://wenku.baidu.com/view/84c20fbd960590c69ec376f5.html 这里有个php的程序能完成这个功能http://blog.csdn.net/y244360439/article/details/8098043 用过ibatis和mybatis的朋友请进 调用service时候 空指针问题,高手请指点 系统加密 Midlet框架代码的疑问 hibernate 学习内容 请教:读取.xml异常 多谢。 用了ibatis,还需要用连接池吗? 急急急急急急急急急,求大神! 百分求JSP分頁程式 请问那里有JDK下载? 如何为音频文件添加音效,比如环绕,混响,回音等。求指点啊!!! 菜鸟问题
URLConnection conn = new URL("http://www.baidu.com").openConnection();
InputStream is = conn.getInputStream();
OutputStream os = new FileOutputStream("c:/save.html");
byte[] buffer = new byte[2048];
int length = 0;
while(-1 != (length = is.read(buffer, 0, buffer.length)))
{
os.write(buffer, 0, length);
}
is.close();
os.close();
隔一段时间让程序运行一次用Timer & TimerTask, LZ百度吧.http://wenku.baidu.com/view/84c20fbd960590c69ec376f5.html