Files
karudhaas/app/Services/DhiyaresService.php
2021-02-05 04:18:29 +05:00

29 lines
747 B
PHP

<?php
namespace App\Services;
use App\Services\Feeds\DhiyaresFeed;
use App\Services\Scrapers\DhiyaresScraper;
class DhiyaresService 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 = (new DhiyaresFeed)->get();
$articlesitems = [];
//Looping through the articles and scraping and while scraping it creates a new instance of the scraper.
foreach ($articles as $article) {
$articlesitems[] = (new DhiyaresScraper)->extract($article["link"], $article["date"]);
}
return $articlesitems;
}
}