Files
karudhaas/app/Services/AdhadhuService.php
2024-01-07 16:58:18 +05:00

30 lines
645 B
PHP

<?php
namespace App\Services;
use App\Services\Feeds\AdhadhuFeed;
use App\Services\Scrapers\AdhadhuScraper;
class AdhadhuService extends Client
{
/**
* Scrap all the rss articles from Adhadhu
*
* @return array
*/
public function scrape(): array
{
$articles = (new AdhadhuFeed)->get();
$articleItems = [];
foreach ($articles as $article) {
$scrapedData = (new AdhadhuScraper)->extract($article["link"], $article["date"]);
if ($scrapedData !== null) {
$articleItems[] = $scrapedData;
}
}
return $articleItems;
}
}