Hey im trying to webscrape a specific thing on a website, like this
<td><a href="javascript:void(0)" class="rankRow"
data-rankkey="25">
Averages
</a>
</td>
<td class="page_speed_602217763">
82.84 </td>
</tr>
Where im trying to get the number 82,84 with the page_speed_** number variying and the on constant that differentiate from the rest of the sourcelist being the text "Averages"
I have tried using the preg_match_all but cant seem to search more than one line and whatevers in between.
My code i have used is the following
<form method="post">
<input type="text" name="Player1Link" placeholder="Player 1"> <br>
</form>
<?php
$Player1Link = $_POST["Player1Link"];
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $Player1Link);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$curlresult = curl_exec($curl);
$pattern = '!data-rankkey="25">[\s]*Averages[\s]*<\/a>[\s]*<\/td>[\s]*<td[^\s]*?class="page_speed_([\d]*)">[\s]*([\d]*.[\d]*)[\s]*</td>[\s]*<\/tr>!';
preg_match_all($pattern, $curlresult, $matches);
print_r($matches);
$P1AvgHigh = $matches[0][3];
echo "<br>";
echo $P1AvgHigh;
curl_close($curl);
?>
With my results being
and the website im using is
https://app.dartsorakel.com/player/stats/8 and the sourcelink view-source:https://app.dartsorakel.com/player/stats/8
Thanks in advance