30 lines
722 B
PHP
30 lines
722 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Services\Scrapers\PsmScraper;
|
|
use Illuminate\Support\Str;
|
|
|
|
class PsmService extends Client
|
|
{
|
|
/**
|
|
* Scrap all the rss articles from mihaaru
|
|
*
|
|
* @return array
|
|
*/
|
|
public function scrape(): array
|
|
{
|
|
$articles = $this->get("https://www.psmnews.mv/feed")["entry"];
|
|
|
|
$articlesitems = [];
|
|
//Looping through the articles and scraping and while scraping it creates a new instance of the scraper.
|
|
foreach ($articles as $article) {
|
|
$link = $article['id'];
|
|
$date = $article['updated'];
|
|
$articlesitems[] = (new PsmScraper)->extract($link, $date);
|
|
}
|
|
|
|
return $articlesitems;
|
|
}
|
|
}
|