0

I am looking to get data from this webpage: http://www.sportinglife.com/greyhounds/racecards/29-10-2014/belle-vue

I have been using jSoup and Java, but can't seem to get the data I am looking for. I need the times of each race (Jump to: 14:18 14:37 14:57 15:17 15:38 15:58 16:18 16:37 16:57 17:17 17:33 17:47 18:04 18:18) and the link that each of them refers to.

I then need to go to each link and print out the 6 dogs in each race.

So the output would look like:

14:18
1 Golden Light
2 Always Late
3 Redley Rooster
4 Redstone Bo Dhu
5 Ballymac Oprah
6 Ballyhill Slide

For each race.

My current code is below, and uses jSoup to extract the runners from the race - but I can't seem to do the first step of getting the race "times" and links to each race page so I can loop through the links and output the runners for each race.

        Document doc = Jsoup.connect(
            "http://www.sportinglife.com/greyhounds/racecards/29-10-2014/belle-vue/card/834800").get();

    Element tableHeader = doc.select("tbody").first();
    Map<String, String> data = new HashMap<>();
    for (Element element : tableHeader.children()) {
        // Here you can do something with each element
            String dog = element.select("td:eq(0)").text();
            String race = element.select("td:eq(2)").text();
            data.put(dog, race);
            System.out.println(dog + " " + race);

        }

Any help is very much appreciated.... thanks! Rob

4
  • Why do you want the links they refer to? Commented Oct 29, 2014 at 10:37
  • I need the links they refer to so that I can loop through the links, and output the 6 dogs for each race. Unless there is an easier way to do this just from the first page? Commented Oct 29, 2014 at 10:39
  • You could loop through all sections. Every section contains the time, plus a table. Every row of this table contains the information you need about the dogs Commented Oct 29, 2014 at 10:45
  • Oh right I see. Do you know how I would do this using jSoup? I'm not too sure on how to loop through the sections... Thanks for your help. Commented Oct 29, 2014 at 10:47

1 Answer 1

1

Looking at your page, the race information are not directly in the second TD but in a link (a) in the second TD, then you need to replace :

 String race = element.select("td:eq(2)").text();

with :

 String race = element.select("td:eq(2) a").text();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.