Good morning, I need to get some data from a website, I am trying some solutions but at the moment I didn't find the right one. This is the code:
<tr><td class="h-text-left"><a href="/soccer/peru/liga-1/binacional-llacuabamba/YasJ57j7/" class="in-match"><span><strong>Binacional</strong></span> - <span>Llacuabamba</span></a></td><td class="h-text-center"><a href="/soccer/peru/liga-1/binacional-llacuabamba/YasJ57j7/">2:1</a></td><td class="table-main__odds colored" data-oid="3o4fmxv464x0x9r5fh"><span><span><span data-odd="2.16"></span></span></span></td><td class="table-main__odds" data-oid="3o4fmxv498x0x0" data-odd="3.31"></td><td class="table-main__odds" data-oid="3o4fmxv464x0x9r5fi" data-odd="3.13"></td><td class="h-text-right h-text-no-wrap">Yesterday</td></tr>
<tr><td class="h-text-left"><a href="/soccer/peru/liga-1/carlos-stein-atletico-grau/EwcmMDIc/" class="in-match"><span>Carlos Stein</span> - <span>Grau</span></a></td><td class="h-text-center"><a href="/soccer/peru/liga-1/carlos-stein-atletico-grau/EwcmMDIc/">1:1</a></td><td class="table-main__odds" data-oid="3o4cvxv464x0x9r5a3" data-odd="2.32"></td><td class="table-main__odds colored" data-oid="3o4cvxv498x0x0"><span><span><span data-odd="2.99"></span></span></span></td><td class="table-main__odds" data-oid="3o4cvxv464x0x9r5a4" data-odd="3.10"></td><td class="h-text-right h-text-no-wrap">Yesterday</td></tr>
You can see td class table-main__odds colored and td class table-main__odds; They are not always in the same position. I tried this approach:
...
function print_odd($odd) {
if (array_key_exists('data-odd', $odd->attr)) {
return $odd->attr['data-odd'];
}
return $odd->children(0)->children(0)->children(0)->children(0)->attr['data-odd'];
}
...
$odd1 = print_odd($odds[$b++]);
$odd2 = print_odd($odds[$b++]);
$odd3 = print_odd($odds[$b++]);
...
This code worked for some years but I think something's changed in the code Any advice?
Thanks
Edit: this is the page address: link website