Sandeep Bansal
Sandeep Bansal

Reputation: 6394

Scrape website to retrieve certain li elements

I'm running a lottery syndicate and want to automate our system to check for the lottery numbers (UK National Lottery)

The url I am getting is: https://www.national-lottery.co.uk/player/p/results/lotto.ftl

and I am using

<?php
$html = file_get_contents("https://www.national-lottery.co.uk/player/p/results/lotto.ftl");
?>

I would like to be able to grab this area of the page, namely the numbers:

enter image description here

The problem is, there is a lot of content on that page and I don't know the first step I would take to break it all down.

Does anyone know a way to do this in PHP or jQuery?

Thanks

Upvotes: -1

Views: 886

Answers (2)

Ronnie
Ronnie

Reputation: 11198

what about an existing rss feed http://www.alllotto.co.uk/rss/latest.rss

Upvotes: 3

Norse
Norse

Reputation: 5757

I would take a look at the PHP Simple HTML DOM Parser. It simplifies scraping and does what you're asking.

Using this, finding LI elements is as easy as this:

foreach($html->find('li') as $element) {
       echo $element . '<br>';
}

Upvotes: 2

Related Questions