문제

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