9

How can I extract the contents of the table located at: /id/2/year/2012/acc-conference">http://espn.go.com/mens-college-basketball/conferences/standings//id/2/year/2012/acc-conference

The few examples I've seen aren't too clear on how to get the contents of the table. Can anyone offer any help?

Johnny Rocket
  • 1,394
  • 3
  • 17
  • 25
  • The `http://espn.go.com/mens-college-basketball/conferences/standings//id/2/year/2012/acc-conference` returns 404 not found error: `The URL you requested does not exist, but you may be interested in the content below`. Are you sure that it's correct url? – Indrek Kõue Nov 23 '11 at 18:22
  • that was the wrong url, here it is: http://espn.go.com/mens-college-basketball/conferences/standings/_/id/2/year/2012/acc-conference – Johnny Rocket Dec 05 '11 at 00:58

1 Answers1

18

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());
            }
        }
    }
B. Anderson
  • 3,079
  • 25
  • 33