如何抓取论坛的帖子的标题和LINK 想看大部分论坛的热门贴子,不想每个论坛登陆进去.什么天崖 猫朴 CSDN 等抓取后 就显示个帖子的标题 和点击数。 然后一点它就自动跳转到具体论坛里,打开相应的帖子。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 先用HttpURLConnection这个类抓页面 再用正则表达式分析 大概如此都不难 自己去看看 给你个抓取页面的方法//返回html代码 public static String getHtmlCode(String httpUrl){ Date before = new Date(); star=before.getTime(); String htmlCode=""; try { InputStream in; URL url = new java.net.URL(httpUrl); HttpURLConnection connection = (HttpURLConnection)url.openConnection(); connection.setConnectTimeout(20000); connection = (HttpURLConnection) url.openConnection(); connection.setRequestProperty("User-Agent","Mozilla/4.0"); connection.connect(); in = connection.getInputStream(); java.io.BufferedReader breader = new BufferedReader(new InputStreamReader(in,"GBK")); String currentLine; while((currentLine=breader.readLine())!=null){ htmlCode+=currentLine; } breader.close(); } catch (Exception e) { e.printStackTrace(); }finally{ Date after=new Date(); end=after.getTime(); ttime=end-star; //System.out.println("执行时间:"+ttime +"秒"); //System.out.println(htmlCode); } return htmlCode; }[ htmlparserhttp://www.pmjava.com/blogview.asp?id=351看看关于htmlparser的例子 网站内容抓取和数据抽取活动都可以使用MetaSeeker软件工具,免费的,全GUI,代码也可以阅读 紧急求助:如何获取文本框的值给jsp中的变量。 单选框提交的问题,不会写关键部分,请指教。 请帮忙看看,将EXCEL导入到MYSQL数据库,是否可以? 请教一个关于数据库操作中遇到的问题 救命!数据库连接问题 String index out of range:6 请问这个错误信息是什么意思 ejb应用服务器的疑问?? 根据当前日期,求30天,或60天之后的日期,代码正确,但是计算结果出现错误??近来看看为什么?` 开发java的环境选择? 谁能解决在oracle的JSP调用问题,高分相送 这是什么错误啊?jdbc中的 关于acegi登录信息输入错误,为什么无法提示
都不难 自己去看看
public static String getHtmlCode(String httpUrl){
Date before = new Date();
star=before.getTime();
String htmlCode="";
try {
InputStream in;
URL url = new java.net.URL(httpUrl);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setConnectTimeout(20000);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("User-Agent","Mozilla/4.0");
connection.connect();
in = connection.getInputStream();
java.io.BufferedReader breader = new BufferedReader(new InputStreamReader(in,"GBK"));
String currentLine;
while((currentLine=breader.readLine())!=null){
htmlCode+=currentLine;
}
breader.close();
} catch (Exception e) {
e.printStackTrace();
}finally{
Date after=new Date();
end=after.getTime();
ttime=end-star;
//System.out.println("执行时间:"+ttime +"秒");
//System.out.println(htmlCode);
}
return htmlCode;
}[