Advertisement
Guest User

Untitled

a guest
Jul 17th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1.     function get($param) {
  2.  
  3.       $big_array = array();
  4.  
  5.       foreach ($param as $k => $v) {
  6.      
  7.       preg_match_all($v, $GLOBALS['post'], $out);
  8.       $out = (isset($out[1][0]) && $out[1][0] != null) ? $out[1][0] : null;
  9.  
  10.       $array = array(
  11.         $k => $out,
  12.                 "pagina" => $GLOBALS['pagina']
  13.       );
  14.  
  15.       $big_array = array_merge($big_array, $array);
  16.  
  17.       }
  18.  
  19.       echo json_encode($big_array);
  20.     }
  21.  
  22.     $i = 1;
  23.     foreach ($receitas[1] as $rc) {
  24.  
  25.         if ($i == 6){break;}else{$i++;}
  26.  
  27.         $url_post = "https://www.receitassupreme.net" . $rc;
  28.  
  29.         if (!@file_get_contents($url_post)) {
  30.             echo "<hr> sem retorno <hr>";
  31.             continue;
  32.         }
  33.  
  34.         $GLOBALS['post'] = file_get_contents($url_post);
  35.  
  36.         $regex = array(
  37.             "imagem"=>"/(https\:\/\/i0.wp.com\/www.receitassupreme.net\/.*?)\?/",
  38.             "titulo"=>"/<h1>(.*?)<\/h1>/s",
  39.             "categoria"=>"/<a href='\/category\/.*?'>(.*?)<\/a>/",
  40.             "ingredientes"=>"/<ul class='ing'>(.*?)<\/ul>/s",
  41.             "preparo"=>"/<div class='mpc'>(.*?)<\/div>(.*?)<\/div>/s"
  42.         );
  43.  
  44.         get($regex);
  45.  
  46.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement