Using JSoup To Extract HTML Table Contents

You probably have this solved by now, but this will go over each table and print out the team name and the Win/Loss column. Adjust for the information you need. The second table is obviously formatted differently, so if you want different information from that table, you will have to adjust further. Let me know if you need any more help.

    Document doc = Jsoup.connect("http://espn.go.com/mens-college-basketball/conferences/standings/_/id/2/year/2012/acc-conference").get();

    for (Element table : doc.select("table.tablehead")) {
        for (Element row : table.select("tr")) {
            Elements tds = row.select("td");
            if (tds.size() > 6) {
                System.out.println(tds.get(0).text() + ":" + tds.get(1).text());
            }
        }
    }

Leave a Comment