Reputation: 1749
I've to invoke this url in my Ubuntu 15.10 ...
http://listeps.cittadellasalute.to.it/?id=01090101
using curl
both from command line and from PHP.
I've notice that no parameters are considered if I simply submit
curl 'http://listeps.cittadellasalute.to.it/?id=01090101'
You can note that no number appears in the result, exactly the same behaviour that you've if submit
curl 'http://listeps.cittadellasalute.to.it/'
The same using this PHP code
<?php
ini_set('display_errors', 1);
$url = 'http://listeps.cittadellasalute.to.it/?id=01090101';
//#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);
$greenWaitingNumber = $xpath->query('/html/body/div/div/div[4]/div[3]/section/p');
foreach( $greenWaitingNumber as $node )
{
echo "Number first green line: " .$node->nodeValue;
echo '<br>';
echo '<br>';
}
?>
How may I using the url parameter both using curl
from command line and in my PHP code?
Upvotes: 0
Views: 1446
Reputation: 1775
The site makes an AJAX request
You didn't mess anything up. The html is empty at first, then it loads code.js, which makes a request to gtotal.php with the id. You can see all this if you open up the network tab in chrome dev tools.
To get the data:
curl http://listeps.cittadellasalute.to.it/gtotal.php?id=01090101
The parameters are sent, but the javascript part never runs.
Upvotes: 1
Reputation: 619
Exporting from postman would result on something like this
curl -X GET 'http://listeps.cittadellasalute.to.it/?id=01090101'
you also can check this tutorial https://www.getpostman.com/docs/postman/sending_api_requests/generate_code_snippets
Upvotes: 1