client = new Client(); } /** * Get all the latest news from the 'އެންމެ ފަސް' section * * @return array */ public function get(): array { $crawler = $this->client->request('GET', "https://raajje.mv/"); $feeds = []; // Find the 'އެންމެ ފަސް' section $articlesContainer = $crawler->filter('.waheed')->each(function ($node) { // Ensure we are in the right section if (strpos($node->text(), 'އެންމެ ފަސް') !== false) { return $node->filter('a')->each(function ($articleNode) { $link = $articleNode->attr('href'); $title = trim($articleNode->filter('div.leading-relaxed')->text()); $date = trim($articleNode->filter('div.mt-3.text-sm')->text()); return [ "title" => $title, "link" => "https://raajje.mv" . $link, "date" => $date ]; }); } }); // Remove null values and flatten the array $articlesContainer = array_filter($articlesContainer); return !empty($articlesContainer) ? array_merge(...$articlesContainer) : []; } }