GuiEnrik

Get Google Images

Dec 18th, 2015
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.48 KB | None | 0 0
  1. <form action="">
  2. <input type="text" name="busca">
  3. <input type="submit" value="Buscar">
  4. </form>
  5.  
  6. <?php
  7.     if(isset($_GET['busca'])){
  8.         $busca = str_replace(array(' '),'+',$_GET['busca']);
  9.        
  10.         //$google = 'https://www.google.com.br/search?q='.$busca.'+cartaz&hl=pt-BR&biw=1600&bih=744&tbas=0&site=imghp&tbs=imgo:1,isz:ex,iszw:1000,iszh:1383&tbm=isch&source=lnt#q='.$busca.'+cartaz&hl=pt-BR&tbas=0&tbs=imgo:1,iszw:1000,iszh:1383,isz:m&tbm=isch';
  11.  
  12.         $google = 'https://www.google.com.br/search?hl=pt-BR&site=imghp&tbm=isch&source=hp&biw=1600&bih=744&q='.$busca.'+cartaz&oq='.$busca.'+cartaz#hl=pt-BR&tbm=isch&q='.$busca.'+cartaz';
  13.  
  14.         echo $google . "<br>";
  15.  
  16.         $ch = curl_init();
  17.         $timeout = 0;
  18.         curl_setopt($ch, CURLOPT_URL, $google);
  19.  
  20.         curl_setopt($ch, CURLOPT_HEADER, false);
  21.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  22.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  23.         curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.1 Safari/537.11');
  24.         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  25.         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  26.         $conteudo = curl_exec ($ch);
  27.         curl_close($ch);
  28.  
  29.         //echo $conteudo;
  30.  
  31.         preg_match_all('/data:image\/jpeg(.+)"]/', $conteudo, $imagens);
  32.  
  33.         //print_r ($imagens)
  34.  
  35.         echo '<img src="'.str_replace(array('\u003d','"]'),'',$imagens[0][8]).'">';
  36.        
  37.         unset($imagens);
  38.  
  39.         //$ImgDownUrl = str_replace(,/^data:image\/[^;]/, 'data:application/octet-stream');
  40.     }
  41. ?>
Add Comment
Please, Sign In to add comment