im using this code:
function doGoogleSearch($searchTerm)
{
//$cx="002000009380213215808:hf9v-g9oyho";
$endpoint = 'web';
$key= 'XXX';
$url = "http://ajax.googleapis.com/ajax/services/se开发者_如何学编程arch/".$endpoint;
$args['q'] = $searchTerm;
$args['v'] = '1.0';
$url .= '?'.http_build_query($args, '', '&');
$ch = curl_init()or die("Cannot init");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$body = curl_exec($ch)or die("cannot execute");
curl_close($ch);
//decode and return the response
return json_decode($body,1);
}
By using this i just got the 1'st 4 results from it.Is there is any way to get the whole search result of google?
http://pear.php.net/package/Services_Google
but google only access you for limited search
As pointed out in the Google Web Search API Class Reference you can use rsz = 8
to get 8 results at a time and start = xxx
to change the "page" of the results (i.e. get the next set of 8)
There is no way to get more than 8 results at a time, and the maximum number of results returned is 64 (see explanation here and, again, in the Class Reference).
Also, the Web Search API is deprecated, you should use the Custom Search API instead.
精彩评论