I am trying to extract data from URL: http://scores.espn.go.com/nba/scoreboard?date=20150410
<?php
include('simple_html_dom.php');
function dlPage($href) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_URL, $href);
curl_setopt($curl, CURLOPT_REFERER, $href);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.125 Safari/533.4");
$str = curl_exec($curl);
curl_close($curl);
$html= str_get_html($str);
foreach($html->find(div[id=events]) as $elm){
var_dump($elm->plaintext);exit;
// this var_dump is return empty string.
}
return $dom;
}
$url = 'http://scores.espn.go.com/nba/scoreboard?date=20150410';
$data = dlPage($url);
print_r($data);
?>
whenever I tried to access internal article tags, I always get null or empty array. Please help me how can I access and extract the data inside the article html5 tags of match scores.