Avas Feed improvements
This commit is contained in:
		@@ -1,4 +1,5 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Services\Feeds;
 | 
			
		||||
 | 
			
		||||
use Goutte\Client;
 | 
			
		||||
@@ -9,29 +10,36 @@ class AvasFeed implements Feed
 | 
			
		||||
 | 
			
		||||
    public function __construct()
 | 
			
		||||
    {
 | 
			
		||||
        $this->client = new Client();        
 | 
			
		||||
    }    
 | 
			
		||||
        $this->client = new Client();
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Return the latest articles from avas
 | 
			
		||||
     *
 | 
			
		||||
     * @return array
 | 
			
		||||
     */
 | 
			
		||||
    public function get() : array
 | 
			
		||||
    public function get(): array
 | 
			
		||||
    {
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
        $crawler = $this->client->request('GET', "https://avas.mv/");
 | 
			
		||||
 | 
			
		||||
        $feeds = [];
 | 
			
		||||
 | 
			
		||||
        $crawler->filter('div[class*="flex rtl -mx-4 flex-wrap md:px-0"] div[class*="w-full md:w-1/3 px-4 mb-7"] div a')->each(function($node) use (&$feeds){
 | 
			
		||||
        $crawler->filter('div[class*="flex rtl -mx-4 flex-wrap md:px-0"] div[class*="w-full md:w-1/3 px-4 mb-7"] div a')->each(function ($node) use (&$feeds) {
 | 
			
		||||
            $feeds[] = [
 | 
			
		||||
                "title" => trim($node->text()),
 | 
			
		||||
                "link" => "https://avas.mv".$node->attr('href')
 | 
			
		||||
                "link" => "https://avas.mv" . $node->attr('href')
 | 
			
		||||
            ];
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        $crawler->filter('div[class*="flex md:-mx-4 flex-wrap md:px-0"] div[class*="w-full md:w-1/5 px-4 mb-8"] div a')->each(function ($node) use (&$feeds) {
 | 
			
		||||
            $feeds[] = [
 | 
			
		||||
                "title" => trim($node->text()),
 | 
			
		||||
                "link" => "https://avas.mv" . $node->attr('href')
 | 
			
		||||
            ];
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        return array_slice($feeds,0,18);
 | 
			
		||||
 | 
			
		||||
        return $feeds;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user