php - Getting more than 10 results Google Search API -
i trying more 10 results form google using search api. know google search api gives 10 results , have call 10 times hundred can't seem working. tried creating while loop loop seems gives me same results on , over.
<?php if(isset($_get['input']) && $_get['input'] != "") { echo "<br />your search results google:<br /><br />"; $i=0; $url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0& key=aizasybacvripno7umqhtjxg4zeq1dtsqa_uod4&cx=014517126046550339258:qoem7fagpyk &num=10&start=".$i."&"."q=".str_replace(' ', '%20', $_get['input']) // sendrequest // note how referer set manually $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_referer, 'http://www.google.com'); $body = curl_exec($ch); curl_close($ch); // now, process json string $json = json_decode($body,true); { foreach ($json['responsedata']['results'] $data) { echo ' <p> ', $data ['title']," ---> <u>google se </u>" ,'<br /> ', '<a href ='.$data['url'].'>'.$data['url']."</a>" , '<br /> ', $data['content'],' </p>'; } $i++; } while($i<3); } ?>
any input appreciated.
ok. try code below:
<?php if(isset($_get['input']) && $_get['input'] != "") { echo "<br />your search results google:<br /><br />"; ($i = 0; $i < 10; $i++) { $url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&key=aizasybacvripno7umqhtjxg4zeq1dtsqa_uod4&cx=014517126046550339258:qoem7fagpyk &num=10&start=".$i."&"."q=".str_replace(' ', '%20', $_get['input']); $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_referer, 'http://www.google.com'); $body = curl_exec($ch); curl_close($ch); $json = json_decode($body,true); foreach ($json['responsedata']['results'] $data) { echo ' <p> ', $data ['title']," ---> <u>google se </u>" ,'<br /> ', '<a href ='.$data['url'].'>'.$data['url']."</a>" , '<br /> ', $data['content'],' </p>'; } } } ?>
Comments
Post a Comment