java : jsoup 网页 table 解析范例

java : jsoup 网页中 table 解析范例

SoupTest.java

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.IOException;

public class SoupTest {
    private String url ;
    // 构造方法
    public SoupTest(String url){
        this.url = url;
    }

    public static void main(String[] args) {
        String url;
        if (args.length==1){
            url = args[0];
        } else {
            System.out.println(" usage: java SoupTest http:// ");
            return;
        }
        SoupTest app = new SoupTest(url);
        app.run();
    }

    private static int table1(Document doc){
        Elements trs = doc.select("table").select("tr");
        int i;
        for ( i=0; i



你可能感兴趣的:(java)