Files
karudhaas/app/Services/HamaService.php
2020-10-13 23:01:02 +05:00

28 lines
698 B
PHP

<?php
namespace App\Services;
use App\Services\Feeds\HamaFeed;
use App\Services\Scrapers\HamaScraper;
class HamaService
{
/**
* 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 HamaFeed)->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 HamaScraper)->extract($article["link"], $article["date"]);
}
return $articlesitems;
}
}