1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| <?php
$surl="http://grenoble.stats.pointstreak.com/templatepreview/teamplayerstats.html?teamid=393369&seasonid=14651";
$doc=new DOMDocument();
$txt = preg_replace('/[^0-9A-Za-z\-\,\'():#$\/_" ]/', "", $txt);
$bret=@$doc->loadHtmlFile($surl);
if (!$bret) {
echo '<div>Erreurs rencontrées en parsant le document, impossible de continuer...</div>';
exit;
}
$simplexml=simplexml_import_dom($doc);
$result=$simplexml->xpath("(//table[@class='tablelines'])[1]/tr[position()=1]/td[position()=1 or position()=2 or position()=3 or position()=4 or position()=5 or position()=6 or position()=7 or position()=8 or position()=9]");
$result2=$simplexml->xpath("(//table[@class='tablelines'])[1]/tr[position()>1]/td[position()=1 or position()=2 or position()=3 or position()=4 or position()=5 or position()=6 or position()=7 or position()=8 or position()=9]");
$n=1;
echo '<table cellspacing="0" cellpadding="3" class="rank" style="width:100%;text-align:center;">';
while(list( , $node) = each($result)) {
echo utf8_decode($n % 9 == 1 ? '<tr style="text-align:center;font-family: Arial,Helvetica,sans-serif;font-size:15px;color:#fff;background:#b70101;">' : '');
echo '<td>', utf8_decode(dom_import_simplexml($node)->textContent), '</td>', ($n % 9 == 0 ? '</tr>' : '');
$n++;
}
while(list( , $node) = each($result2)) {
$data[$n % 9] = trim(dom_import_simplexml($node)->textContent);
if ($n % 9 == 0) {
if ($data[2] == 'Grenoble') {
echo '<tr>' ;
}
else {
echo '<tr style="font-family: Arial,Helvetica,sans-serif;font-size:12px;color:#000;">' ;
}
foreach ($data as $d) {
echo '<td>', utf8_decode($d), '</td>';
}
echo '</tr>';
}
$n++;
}
?> |
Partager