Files
karudhaas/app/Services/SunService.php

27 lines
689 B
PHP

<?php
namespace App\Services;
use App\Services\Feeds\SunFeed;
use App\Services\Scrapers\SunScraper;
class SunService
{
/**
* 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 SunFeed)->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 SunScraper)->extract("https://sun.mv/".$article["id"]);
}
return $articlesitems;
}
}