client = new Client(); } public function extract($url) { $crawler = $this->client->request('GET', $url); // Extracting title - checking for multiple class names $title = $crawler->filter('.text-3xl')->first()->text(); // Extracting article content $crawler->filter('.container .dv')->each(function ($node) { $this->content[] = $node->text(); }); // Extracting topics $this->topics = []; $crawler->filter('.related-tags-holder a')->each(function ($node) { $this->topics[] = [ "name" => $node->text(), "slug" => str_replace("/", "", $node->attr('href')) ]; }); // Returning extracted data return [ 'source' => 'Voice', 'title' => $title, 'og_title' => $crawler->filter('meta[property*="og:title"]')->first()->attr('content'), 'image' => $crawler->filter('meta[property="og:image"]')->first()->attr('content'), 'content' => $this->content, 'url' => $url, 'date' => Carbon::now(), 'guid' => str_replace("https://voice.mv/", "", $url), 'author' => $this->author, 'topics' => $this->topics ]; } }