Files
karudhaas/app/Services/MiadhuService.php
2020-10-03 03:21:34 +05:00

28 lines
708 B
PHP

<?php
namespace App\Services;
use App\Services\Feeds\MiadhuFeed;
use App\Services\Scrapers\MiadhuScraper;
class MiadhuService
{
/**
* Scrap all the rss articles from Sun
*
* @return array
*/
public function scrape(): array
{
//Return only the rss that contains "news" keyboard in its url
$articles = (new MiadhuFeed)->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 MiadhuScraper)->extract($article["link"], $article["date"]);
}
return $articlesitems;
}
}