From d33c727b68594dbc1404e8409b361309c6968b2b Mon Sep 17 00:00:00 2001 From: Mohamed Jinas Date: Fri, 5 Feb 2021 03:39:45 +0500 Subject: [PATCH] Update ThiladhunScraper.php --- app/Services/Scrapers/ThiladhunScraper.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/Services/Scrapers/ThiladhunScraper.php b/app/Services/Scrapers/ThiladhunScraper.php index e448ab1..dd6c988 100644 --- a/app/Services/Scrapers/ThiladhunScraper.php +++ b/app/Services/Scrapers/ThiladhunScraper.php @@ -13,6 +13,7 @@ class ThiladhunScraper protected $guid; protected $image; protected $author; + protected $topics = []; /** * __construct. @@ -52,6 +53,17 @@ class ThiladhunScraper $this->image = $node->attr('src'); }); + $crawler->filter('.entry-tags a')->each(function ($node) { + if(!preg_match('/[^A-Za-z0-9-]/', basename($node->attr('href')))) + { + $this->topics[] = [ + "name" => $node->text(), + "slug" => basename($node->attr('href')) + ]; + } + + }); + $crawler->filter('a[class*="entry-author__name"]')->each(function ($node) { $this->author = $node->text(); }); @@ -67,7 +79,7 @@ class ThiladhunScraper 'url' => $url, 'author' => $this->author, 'guid' => $this->guid, - 'topics' => [ + 'topics' => $this->topics ? : [ [ "name" => "ވަކި މަޢުލޫއެއް ނޭންގެ", "slug" => "no-specific-topic"