Reputation: 1300
I want scrape data from other website page which loading table's data dynamically. I am using Php and Simple Html Dom for scraping after searching lot did not find any solutions how to scrape dynamic data from web page? Or there is another way to do this?
$url = "https://fantasy.premierleague.com/a/leagues/standings/313/classic";
$html = file_get_html($url);
$html->find('div#ismr-classic-standings');
foreach($html->find('table.ism-table--standings tr') as $row){
//But count($row)=0 due to late loading html in table.
}
Upvotes: 2
Views: 1446
Reputation: 11
Your page is calling another link and retrieving JSON data; try this code:
include "simple_html_dom.php";
$MyWebsite = 'https://fantasy.premierleague.com/drf/leagues-classic-standings/313?phase=1&le-page=1&ls-page=1';
$html = file_get_html($MyWebsite);
$JSON_value = json_decode($html, true);
$results = $JSON_value['standings']['results'];
foreach($results as $result) {
echo $result['entry_name'] . '->' . $result['event_total'] . '<br/>';
}
Upvotes: 1