Files
karudhaas/app/Services/PsmService.php
2020-09-22 23:09:24 +05:00

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;
}
}