je dois gratter cette page HTML ...rigth Xpath pour les éléments HTML
http://www1.usl3.toscana.it/default.asp?page=ps&ospedale=3
.... en utilisant PHP et XPath pour obtenir les valeurs comme sous la chaîne "CODICE BIANCO"
(NOTE: vous pourriez voir différentes valeurs dans cette page si vous essayez de le parcourir ... ce n'est pas grave .. ,, ils changent dinamically ....)
J'utilise cet exemple de code PHP pour imprimer la valeur ...
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
include "./tmp/vendor/autoload.php";
$url = 'http://www1.usl3.toscana.it/default.asp?page=ps&ospedale=3';
//$xpath_for_parsing = '/html/body/div/div[2]/table[2]/tbody/tr[1]/td/table/tbody/tr[3]/td[1]/table/tbody/tr[11]/td[3]/b';
$xpath_for_parsing = '//*[@id="contentint"]/table[2]/tbody/tr[1]/td/table/tbody/tr[3]/td[1]/table/tbody/tr[11]/td[3]/b';
//#Set CURL parameters: pay attention to the PROXY config !!!!
$ch = curl_init();
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_PROXY, '');
$data = curl_exec($ch);
curl_close($ch);
$dom = new DOMDocument();
@$dom->loadHTML($data);
$xpath = new DOMXPath($dom);
$colorWaitingNumber = $xpath->query($xpath_for_parsing);
$theValue = 'N.D.';
foreach($colorWaitingNumber as $node)
{
$theValue = $node->nodeValue;
}
print $theValue;
?>
J'ai extrait le XPath en utilisant les deux consoles Web Chrome et Firefox ...
Suggestions/exemples ?
Cela fonctionne maintenant ... des outils de remplacement pour extraire xpath pour mes éléments de page HTML? – Cesare