Files
karudhaas/app/Services/DhuvasService.php
2020-08-26 14:09:25 +05:00

30 lines
805 B
PHP

<?php
namespace App\Services;
use App\Services\Scrapers\DhuvasScraper;
use Illuminate\Support\Str;
class DhuvasService 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 = $this->get("https://dhuvas.mv/feed")["channel"]["item"];
$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'];
$date = $article['pubDate'];
$articlesitems[] = (new DhuvasScraper)->extract($link,$date);
}
return $articlesitems;
}
}