Vnews support

This commit is contained in:
2020-10-03 03:41:11 +05:00
parent cf4e6267b6
commit af2965f7ba
4 changed files with 162 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
<?php
namespace App\Services;
use App\Services\Scrapers\VnewsScraper;
class VnewsService 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://www.vnews.mv/rss")["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 VnewsScraper)->extract($link, $date);
}
return $articlesitems;
}
}