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"