I'm trying to scrape this web page ...
https://www.aslteramo.it/SISWebOnLine/ProntoSoccorso.aspx
.... using PHP and XPath to get the number values under the red, yellow, green and white colored circles.
(NOTE: you could see different value in that page if you try to browse it ... it doesn't matter ..,, it change dinamically .... )
I'm trying to use this PHP code sample to print the value ...
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
$url = 'http://www.aslteramo.it/SISWebOnLine/ProntoSoccorso.aspx';
$xpath_for_parsing = '/html/body/div/form/div[3]/div[2]/div[3]/div/div/div[2]/table/tbody/tr[2]/td[4]/table/tbody/tr[1]/td';
//#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;
?>
Note that, to get the elements XPath, you've to disable javascript in your browser because the mouse right click is disabled.
I've seen that in the page there is a POST request ...
.... but I don't know how to modify my code to do the request and then how to extract my values ...
Any help will be appreciated.
Thank you in advance