Googleinurl

Function Google API de busca

Mar 4th, 2013
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. <?php
  2.  
  3. function google($dork,$pag){
  4. $ch = curl_init();
  5. $opcoes = array(CURLOPT_URL => "http://ajax.googleapis.com/ajax/services/search/web?v=2.0&q={$dork}&start={$pag}",
  6.     CURLOPT_HEADER => false,
  7.     CURLOPT_RETURNTRANSFER=>1,
  8.     CURLOPT_REFERER=>"http://google.com");
  9. curl_setopt_array($ch, $opcoes);
  10. $resultado= curl_exec($ch);
  11. curl_close($ch);
  12. //Processando a string Json
  13. $json = json_decode($resultado);
  14. //Array com os resultados
  15. $array = $json->responseData->results;
  16. //Total de resultados retornados
  17. foreach($array as $key){
  18. $resultado_url = $key->url;
  19. $resultado_url = urldecode($resultado_url);
  20. echo "{$resultado_url}\n";
  21. }
  22. }
  23.  
  24. $i = 0;
  25. while($i<40){
  26. echo google("noticias+site:br+inurl:id?=",$i);
  27. $i=$i+4;
  28. }
  29. ?>
Add Comment
Please, Sign In to add comment