1

What is the best way to extract data from a table from an url?

In short I need to get the actual data from the these 2 tables at: http://www.oddsportal.com/sure-bets/

In this example the data would be "Paddy power" and "3.50" See this image:

(Sorry for posting image like this, but I still need reputation, i will edit later) http://img837.imageshack.us/img837/3219/odds2.png

I have tried with Jsoup, but i dont know if this is the best way? And I can't seem to navigate correctly down the tables, I have tried things like this:

    tables = doc.getElementsByAttributeValueStarting("class", "center"); 
    link = doc.select("div#col-content > title").first();
    String text1 = doc.select("div.odd").text();

The tables thing seem to get some data, but doesn't include the text in the table

4

1 回答 1

1

对不起。您要检索的第二个字段由 JavaScript 填充。Jsoup 不执行 JavaScript。要选择第一行的标题,您可以使用:

Document doc = Jsoup.connect("http://www.oddsportal.com/sure-bets/").get();
     Elements tables = doc.select("table.table-main").select("tr:eq(2)").select("td:eq(2)");
     System.out.println(tables.select("a").attr("title"));

用于可视化的链选择。

于 2013-05-28T16:56:55.563 回答