Retrieving Google Search Results

I read your message on

simple php script to get google keyword search completion

and I was wondering how would you choose the echo on the next page? here is my script ..

$ search = 'query';

$ x = json_decode (file_get_contents (' http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q= ', urlencode ($ search)));

echo $ X-> responseData-> Results [0] → URL;

I was able to “track” the url, I was stuck in going to the next page and echoed from the next url

thank you sir

+3
source share
2 answers

You change the index:

echo $x->responseData->results[1]->url;

Skip all:

foreach ($x->responseData->results as $r) {
    echo $r->url, "\n";
}

var_dump($x);.

, start, :

$x = json_decode(
    file_get_contents(
    'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&start=4&q='
    . urlencode( $search )));

8 4 rsz=large.

+5

, Google , : object(stdClass)#1 (3) { ["responseData"]=> NULL ["responseDetails"]=> string(143) "The Google Web Search API is no longer available. Please migrate to the Google Custom Search API (https://developers.google.com/custom-search/)" ["responseStatus"]=> int(403) }

API Google (https://developers.google.com/custom-search/). , .

+1

All Articles