From 2c4f670811dc14d38247056affbfc42944e66efa Mon Sep 17 00:00:00 2001 From: Mohamed jinas Date: Sat, 13 Jan 2024 03:35:37 +0500 Subject: [PATCH] WIP --- app/Services/Scrapers/AdhadhuScraper.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Services/Scrapers/AdhadhuScraper.php b/app/Services/Scrapers/AdhadhuScraper.php index a59d8ae..23d678a 100644 --- a/app/Services/Scrapers/AdhadhuScraper.php +++ b/app/Services/Scrapers/AdhadhuScraper.php @@ -35,8 +35,12 @@ class AdhadhuScraper // Extract image URL $this->image = $crawler->filter('img.img-fluid.hero-img')->first()->attr('src'); - // Extract author name - $this->author = $crawler->filter('.MuiAvatar-circle img')->first()->attr('alt'); + $authorNode = $crawler->filter('.MuiAvatar-circle img'); + if ($authorNode->count() > 0) { + $this->author = $authorNode->first()->attr('alt'); + } else { + $this->author = 'unknown'; // Set to 'Unknown' if author element is not found + } // Extract content $crawler->filter('.body > p')->each(function ($node) {