Advertisement
Guest User

Untitled

a guest
Jul 30th, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public function getAllPictures(Client $client,request $request){
  2.        
  3.         $crawler = $client->request('GET','http://www.watchthedeer.com/photos');
  4.         $allPictures = $crawler->filter("[href*='looping_images']")->each(function ($node, $i) use ($client) {
  5.             $link = $node->attr('href');
  6.             $go = $client->request('GET',$link);
  7.             $filter = $go->filter("head > script")->each(function( $node, $i) {
  8.                 $text =  $node->text();
  9.                 preg_match_all("/([|.|\w|\s|]?)*.(jpg)/", $text,$m);
  10.                 $all = [];
  11.                 foreach($m[0] as $key =>$ty){
  12.                     $all[$key] = ($key + 1).'-'.$ty;
  13.                 }
  14.                 return $all;
  15.                
  16.             });
  17.             return $filter;
  18.         });
  19.  
  20.         echo '<pre>';
  21.         $results  = collect($allPictures);
  22.         foreach($results->flatten()->all() as $result){
  23.             echo $result;
  24.         }
  25.     }
  26.  
  27. //druga
  28.  
  29. public function fistAndLast(Client $client,request $request){
  30. $crawler = $client->request('GET','http://www.watchthedeer.com/photos');
  31.         $allPictures = $crawler->filter("[href*='looping_images']")->each(function ($node, $i) use ($client) {
  32.             $link = $node->attr('href');
  33.             $go = $client->request('GET',$link);
  34.             $filter = $go->filter("head > script")->each(function( $node, $i) {
  35.                 $text =  $node->text();
  36.                 preg_match_all("/([|.|\w|\s|]?)*.(jpg)/", $text,$m);
  37.                 $all = [];
  38.                 foreach($m[0] as $key =>$ty){
  39.                     $all[$key] = ($key + 1).'-'.$ty;
  40.                 }
  41.                  $collection = collect($all);
  42.                  $one = $collection->first();
  43.                  $two = $collection->last();
  44.                  $all =[$one,$two];
  45.                  return $all;
  46.                
  47.             });
  48.             return $filter;
  49.         });
  50.         echo '<pre>';
  51.         $results  = collect($allPictures);
  52.         foreach($results->flatten()->all() as $result){
  53.             echo $result;
  54.         }
  55.         echo '</pre>';
  56. }
  57.  
  58. //trzecia
  59. public function fistAndLast(Client $client,request $request){
  60. $crawler = $client->request('GET','http://www.watchthedeer.com/photos');
  61.         $allPictures = $crawler->filter("[href*='looping_images']")->each(function ($node, $i) use ($client) {
  62.             $link = $node->attr('href');
  63.             $go = $client->request('GET',$link);
  64.             $filter = $go->filter("head > script")->each(function( $node, $i) {
  65.                 $text =  $node->text();
  66.                 preg_match_all("/([|.|\w|\s|]?)*.(jpg)/", $text,$m);
  67.                 $all = [];
  68.                 foreach($m[0] as $key =>$ty){
  69.                     $all[$key] = ($key + 1).'-'.$ty;
  70.                 }
  71.                  $collection = collect($all);
  72.                 $all = $collection->nth(5)->all();
  73.                 return $all;
  74.                
  75.             });
  76.             return $filter;
  77.         });
  78.         echo '<pre>';
  79.         $results  = collect($allPictures);
  80.         foreach($results->flatten()->all() as $result){
  81.             echo $result;
  82.         }
  83.         echo '</pre>';
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement