31 lines
818 B
PHP
31 lines
818 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Services\Feeds\OneOnlineFeed;
|
|
use App\Services\Scrapers\OneOnlineScraper;
|
|
|
|
class OneOnlineService
|
|
{
|
|
/**
|
|
* 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 OneOnlineFeed)->get();
|
|
$articlesitems = [];
|
|
//Looping through the articles and scraping and while scraping it creates a new instance of the scraper.
|
|
foreach ($articles as $article) {
|
|
$scraped_article = (new OneOnlineScraper)->extract($article["link"]);
|
|
if (!is_null($scraped_article)) {
|
|
$articlesitems[] = $scraped_article;
|
|
}
|
|
}
|
|
|
|
return $articlesitems;
|
|
}
|
|
}
|