A few days ago someone asked me …
… how to use the eHttpClient PHP cURL Class to count the Google search results. So this here is the script to use. It's simple and basic but it has one small catch. I ask for the very last page of search results to get the most 'accurate' number as Google has been showing not really accurate results sience last update.
PHP Script to count Google results:
<?
function ggResultCount($query,$filter=1){
$Url="http://www.google.com/search?num=10&start=990&filter=%d&safe=off&hl=en&hl=en&q=".
urlencode(strtolower($query));
$hc=new eHttpClient();
$html=$hc->get($Url);
if(!preg_match("@Results <b>([0-9,]+)<\b> - <b>([0-9,]+)<\b> .*? <b>([0-9,]+)<\b>@si",
$html,$inf)){ return false; }
$ResCnt=$inf[3];
return (int)preg_replace("/[^0-9]/","",$ResCnt);
}
?>
Keep Is Short and Simple I always say:)
Post Feedback