I am trying hard to find a way to get the number of Google search results using PHP? I have search Google and stackoverflow but have not found anything suitable.
I want to know how can I do this using PHP.
I am trying hard to find a way to get the number of Google search results using PHP? I have search Google and stackoverflow but have not found anything suitable.
I want to know how can I do this using PHP.
When not using APIs:
$content = file_get_contents('https://www.google.com/search?q=test');
preg_match('/<div class="sd" id="resultStats">.*?([0-9\.\,]+).*?<\/div>/', $content, $matches);
var_dump($matches[1]);
Although i would advise against this way of (automated) queries.
you can parse google search page.
in the return page, there has number of google search result .
such as,
when we search stackoverflow
in google search box, these text will appear under google search box:
About 34,800,000 results (0.79 seconds)