31 lines
		
	
	
		
			842 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			842 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Services;
 | |
| 
 | |
| use App\Services\Scrapers\FunadhooTimesScraper;
 | |
| use Illuminate\Support\Str;
 | |
| 
 | |
| 
 | |
| class FunadhooTimesService extends Client
 | |
| {
 | |
|     /**
 | |
|      * Scrap all the rss articles from Press
 | |
|      *
 | |
|      * @return array
 | |
|      */
 | |
|     public function scrape(): array
 | |
|     {
 | |
|         //Return only the rss that contains "news" keyboard in its url
 | |
|         $articles = $this->get("https://funadhootimes.com/rss.xml")["channel"]["article"];
 | |
|         $articlesitems = [];
 | |
|         //Looping through the articles and scraping and while scraping it creates a new instance of the scraper.
 | |
|         foreach ($articles as $article) {
 | |
|             $link = $article['link'];
 | |
|             $title = $article['title'];
 | |
|             $articlesitems[] = (new FunadhooTimesScraper)->extract($link, $title);
 | |
|         }
 | |
| 
 | |
|         return $articlesitems;
 | |
|     }
 | |
| }
 |