I am attempting to scrape a website using the PHP Simple HTML DOM Parser
It works fine but when I try to get the data from this link.
I want to scrape the following text in the tag below but find impossible: 167/3 (48.0 ov)
<div class="team-1-name">
India
<span class="innings-1-score ">457</span> &
<span class="innings-1-score innings-current">167/3 (48.0 ov)</span>
</div>
I've tried numerous combinations like the below without success:
$file_string = file_get_contents("http://www.espncricinfo.com/england-v-india-2014/engine/match/667711.html");
foreach($html->find('div[class=team-1-name]') as $team) {
echo $team
foreach($team->find('span[class=innings-1-score innings-current]') as $inn) {
echo $inn;
}
}
echo $team works and gives me "India" as expected but
echo $inn returns nothing.
What am I doing wrong? I have been wracking my brain about this for days - any help is much appreciated.
Thanks in advance.
$teamis not JSON but$innis? Do you know how I might parse the JSON?simple-html-domsince the values inside the div are dynamically (live) fed by ajax, check (most likely) the network tab on developer console and check incoming network