Miadhu News Support

This commit is contained in:
2020-10-03 03:21:34 +05:00
parent 3b50c8058f
commit cf4e6267b6
5 changed files with 200 additions and 1 deletions

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Services;
use App\Services\Feeds\MiadhuFeed;
use App\Services\Scrapers\MiadhuScraper;
class MiadhuService
{
/**
* Scrap all the rss articles from Sun
*
* @return array
*/
public function scrape(): array
{
//Return only the rss that contains "news" keyboard in its url
$articles = (new MiadhuFeed)->get();
$articlesitems = [];
//Looping through the articles and scraping and while scraping it creates a new instance of the scraper.
foreach ($articles as $article) {
$articlesitems[] = (new MiadhuScraper)->extract($article["link"], $article["date"]);
}
return $articlesitems;
}
}