apache tags scrape看一下源代码吧

解决方案 »

  1.   

    import java.io.*;
    import java.net.*;
    public class king{
    public king(){
    try{
    URL url=new URL("http://www.csdn.net");
    BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
    String i;
    while((i=in.readLine())!=null){
    System.out.println(i);
    }
    }catch(IOException e){
    }
    }public static void main(String[] agag){
    new king();
    }
    }
      

  2.   

    现在网页中用<p></p>的太少了,你自己找一个带标记的网页试。import java.net.*;
    import java.io.*;public class Test {
      URL url;
      InputStream in;
      String html = "";
      String temp;
      int p1=0,p2=0;  public Test(){
        try {
          url = new URL("http://www.XXXXX.com");
        }
        catch (MalformedURLException ex) {
        }
        try {
          in = url.openStream();
        }
        catch (IOException ex1) {
        }
      }  public void Read(){
        BufferedReader r = null;
        try {
          r = new BufferedReader(new InputStreamReader(url.openStream()));
        }
        catch (IOException ex) {
        }
        try {
          String str;
          while ( (str = r.readLine()) != null) {
            html = html.concat(str);
          }
          while(p2+1<=html.lastIndexOf("</p>")){
            p1 = html.indexOf("<p>",p2);
            p2 = html.indexOf("</p>",p2+1);
            temp = html.substring(p1+3,p2);
            System.out.println(temp);
          }
        }
        catch (MalformedURLException e) {
          e.printStackTrace();
        }
        catch (IOException ignored) {
          ignored.printStackTrace();
        }
      }  public static void main(String[] args) {
        Test test = new Test();
        test.Read();
      }
    }<------ 树欲静而风不止 ------>
      

  3.   

    自己当字符串搜索<p>来处理了,呵呵,多谢大家的参与;