자바 html 분석 table

2319 단어
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class test11 {

    public static void main(String[] args) {// TODO Auto-generated method stub
        String html = "html  ";
        Document doc = Jsoup.parse(html);
        Elements rows = doc.select("table[class=h_list-table]").get(0).select("tr");
        
        if (rows.size() == 1) {
                System.out.println("    ");
        }else {
            for(int i=1;i)
            {
                System.out.println("-----------------------------------------------------------------");
                Element row = rows.get(i);
                    System.out.println("    :" + row.select("td").get(0).text());
                System.out.println("    :" + row.select("td").get(1).text());   
                System.out.println("-----------------------------------------------------------------");
            }
        }
    }
}

좋은 웹페이지 즐겨찾기