想看大部分论坛的热门贴子,不想每个论坛登陆进去.什么天崖 猫朴 CSDN 等抓取后 就显示个帖子的标题 和点击数。 然后一点它就自动跳转到具体论坛里,打开相应的帖子。

解决方案 »

  1.   

    先用HttpURLConnection这个类抓页面 再用正则表达式分析 大概如此
    都不难 自己去看看
      

  2.   

    给你个抓取页面的方法//返回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;
    }[
      

  3.   

    htmlparserhttp://www.pmjava.com/blogview.asp?id=351看看关于htmlparser的例子
      

  4.   

    网站内容抓取和数据抽取活动都可以使用MetaSeeker软件工具,免费的,全GUI,代码也可以阅读