Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function getAllPictures(Client $client,request $request){
- $crawler = $client->request('GET','http://www.watchthedeer.com/photos');
- $allPictures = $crawler->filter("[href*='looping_images']")->each(function ($node, $i) use ($client) {
- $link = $node->attr('href');
- $go = $client->request('GET',$link);
- $filter = $go->filter("head > script")->each(function( $node, $i) {
- $text = $node->text();
- preg_match_all("/([|.|\w|\s|]?)*.(jpg)/", $text,$m);
- $all = [];
- foreach($m[0] as $key =>$ty){
- $all[$key] = ($key + 1).'-'.$ty;
- }
- return $all;
- });
- return $filter;
- });
- echo '<pre>';
- $results = collect($allPictures);
- foreach($results->flatten()->all() as $result){
- echo $result;
- }
- }
- //druga
- public function fistAndLast(Client $client,request $request){
- $crawler = $client->request('GET','http://www.watchthedeer.com/photos');
- $allPictures = $crawler->filter("[href*='looping_images']")->each(function ($node, $i) use ($client) {
- $link = $node->attr('href');
- $go = $client->request('GET',$link);
- $filter = $go->filter("head > script")->each(function( $node, $i) {
- $text = $node->text();
- preg_match_all("/([|.|\w|\s|]?)*.(jpg)/", $text,$m);
- $all = [];
- foreach($m[0] as $key =>$ty){
- $all[$key] = ($key + 1).'-'.$ty;
- }
- $collection = collect($all);
- $one = $collection->first();
- $two = $collection->last();
- $all =[$one,$two];
- return $all;
- });
- return $filter;
- });
- echo '<pre>';
- $results = collect($allPictures);
- foreach($results->flatten()->all() as $result){
- echo $result;
- }
- echo '</pre>';
- }
- //trzecia
- public function fistAndLast(Client $client,request $request){
- $crawler = $client->request('GET','http://www.watchthedeer.com/photos');
- $allPictures = $crawler->filter("[href*='looping_images']")->each(function ($node, $i) use ($client) {
- $link = $node->attr('href');
- $go = $client->request('GET',$link);
- $filter = $go->filter("head > script")->each(function( $node, $i) {
- $text = $node->text();
- preg_match_all("/([|.|\w|\s|]?)*.(jpg)/", $text,$m);
- $all = [];
- foreach($m[0] as $key =>$ty){
- $all[$key] = ($key + 1).'-'.$ty;
- }
- $collection = collect($all);
- $all = $collection->nth(5)->all();
- return $all;
- });
- return $filter;
- });
- echo '<pre>';
- $results = collect($allPictures);
- foreach($results->flatten()->all() as $result){
- echo $result;
- }
- echo '</pre>';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement