32 lines
773 B
PHP
32 lines
773 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Services\Scrapers\ThePressScraper;
|
|
use App\Services\Feeds\ThePressFeed;
|
|
use Illuminate\Support\Str;
|
|
|
|
class ThePressService extends Client
|
|
{
|
|
/**
|
|
* Scrap all the rss articles from Press
|
|
*
|
|
* @return array
|
|
*/
|
|
public function scrape(): array
|
|
{
|
|
//Return only the rss that contains "news" keyboard in its url
|
|
$articles = (new ThePressFeed)->get();
|
|
|
|
|
|
$articlesitems = [];
|
|
//Looping through the articles and scraping and while scraping it creates a new instance of the scraper.
|
|
foreach ($articles as $article) {
|
|
$link = $article['link'];
|
|
$articlesitems[] = (new ThePressScraper)->extract($link);
|
|
}
|
|
|
|
return $articlesitems;
|
|
}
|
|
}
|