28 lines
708 B
PHP
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;
|
|
}
|
|
}
|