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<rows.size();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("-----------------------------------------------------------------"); } } } }