Вопрос

Is there some sort of web API that allows me to send a search query to google and get the number of search results? I have been googling for something like this, and could not find anything.

Thank you,

Marina

Это было полезно?

Решение

well here is the Code with little description 1. PHP curl enabled curl extension in php.ini 2. Google Ajax api

and i hope this code help you... i checked on localhost working fine for me .

<?php
echo Google_result('Hamza');

function Google_result($search){
$url="http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=search:".$search."&filter=0";
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_NOBODY, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$json = curl_exec($ch);
curl_close($ch);
$data=json_decode($json,true);
if($data['responseStatus']==200)
return $data['responseData']['cursor']['resultCount'];
else
return false;
}
?>

Другие советы

yes Google Ajax api will help you to do this

http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=search:".$search."&filter=0
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top