29 lines
		
	
	
		
			748 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			748 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Services;
 | |
| 
 | |
| use App\Services\Scrapers\ThiladhunScraper;
 | |
| 
 | |
| class ThiladhunService extends Client
 | |
| {
 | |
|     /**
 | |
|      * Scrap all the rss articles from Thiladhun
 | |
|      *
 | |
|      * @return array
 | |
|      */
 | |
|     public function scrape(): array
 | |
|     {
 | |
|         //Return only the rss that contains "news" keyboard in its url
 | |
|         $articles = $this->get("https://thiladhun.com/feed")["channel"]["item"];
 | |
| 
 | |
|         $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'];
 | |
|             $articlesitems[] = (new ThiladhunScraper)->extract($link);
 | |
|         }
 | |
| 
 | |
|         return $articlesitems;
 | |
|     }
 | |
| }
 |