I am trying to find and extract the "About 16,600,000 results (0.69 seconds)" text from the Google results page. Not the results, just the String text. After extracting, i want to save the result in an Array and to repeat it twice with other keywords. Afterwards, i will loop through the Array to print it in a table. I don't know why, but if i try to find "results" on the page i always tells me it did not find anything. Current code:
<?php
$url = "https://www.google.co.uk/#q=cheese";
$html = file_get_contents($url);
if (strpos($html, "results") !== false) {
echo "found";
} else {
echo "not found";
}
?>
I think it's because https://www.google.co.uk/#q=cheese only returns a html document, which runs some JavaScript code that fetches the search result in a second call.
(You can disable JavaScript in your browser and visit the page to "see" what file_get_contents would see)