fix dhiyares

This commit is contained in:
Mohamed jinas
2024-01-06 15:58:59 +05:00
parent 1b56bcb510
commit b7bda9b09e
3 changed files with 33 additions and 18 deletions

View File

@@ -14,15 +14,16 @@ class DhiyaresService extends Client
*/
public function scrape(): array
{
//Return only the rss that contains "news" keyboard in its url
$articles = (new DhiyaresFeed)->get();
$articlesitems = [];
//Looping through the articles and scraping and while scraping it creates a new instance of the scraper.
$articleItems = [];
foreach ($articles as $article) {
$articlesitems[] = (new DhiyaresScraper)->extract($article["link"], $article["date"]);
$scrapedData = (new DhiyaresScraper)->extract($article["link"], $article["date"]);
if ($scrapedData !== null) {
$articlesitems[] = $scrapedData;
}
}
return $articlesitems;
return $articleItems;
}
}