Files
karudhaas/app/Services/DhenService.php
2020-08-20 03:48:56 +05:00

29 lines
723 B
PHP

<?php
namespace App\Services;
use App\Services\Scrapers\DhenScraper;
class DhenService 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://dhen.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'];
$articlesitems[] = (new DhenScraper)->extract($link);
}
return $articlesitems;
}
}