Yoshidk
Yoshidk

Reputation: 459

Get tabledata from html, JSOUP

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

Upvotes: 1

Views: 502

Answers (1)

vacuum
vacuum

Reputation: 2273

Sorry, man. The second field you want to retrieve is filled by JavaScript. Jsoup does not execute JavaScript. To select title of first row you can use:

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"));

Chain selects used for visualization.

Upvotes: 1

Related Questions