Zaviyani news intergration

This commit is contained in:
2021-01-11 13:46:06 +05:00
parent 31404d2f48
commit bb5602f911
5 changed files with 202 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Services;
use App\Services\Scrapers\ZaviyaniScraper;
use App\Services\Feeds\ZaviyaniFeed;
use Illuminate\Support\Str;
class ZaviyaniService 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 = (new ZaviyaniFeed)->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 ZaviyaniScraper)->extract($article["link"], $article["date"]);
}
return $articlesitems;
}
}