2010-12-04 2 views
-1

イム:どのようにPHPのAPIからすべてのGoogle検索結果を取得するには?このコードを使用して

function doGoogleSearch($searchTerm) 
    { 
    //$cx="002000009380213215808:hf9v-g9oyho";   
    $endpoint = 'web'; 
    $key= 'XXX'; 
    $url = "http://ajax.googleapis.com/ajax/services/search/".$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); 
    } 

これを使用することでは、私はちょうどグーグルの全検索結果を取得する方法があるit.Isから第1 '4の結果を得ましたか。

答えて

0

としては、あなたがより多くを取得する方法はありません

(すなわち8の次のセットを取得します)8時の結果とstart = xxxは結果の「ページ」を変更してもらうためにrsz = 8を使用することができますin the Google Web Search API Class Reference指摘しました一度に8つ以上の結果が返され、返される結果の最大数は64です(説明hereを参照)。in the Class Referenceを参照してください。

また、Web Search APIは廃止予定です。代わりにCustom Search APIを使用してください。

+0

限定された検索にアクセスGoogle?それはこのスタート= xxxは似ているのですか? –

+0

が得られました.thanx alot.iはstartの値を変更して全体の結果を得ることができます。 –

+0

Array([responseData] => [responseDetails] =>範囲外の開始[responseStatus] => 400) –

関連する問題