client = new Client; } public function extract($url, $date) { $crawler = $this->client->request('GET', $url); $crawler->filter('div[id*="article-content"] div > p')->each(function ($node) { $this->content[] = $node->text(); }); if ($crawler->filter('.twitter-user')->count() > 0) { $this->author = $crawler->filter('.twitter-user')->first()->text(); } //Remove all the alphabets from string //preg_replace("/[a-zA-Z]/", "",$string); return [ 'source' => 'RaajjeMv', 'title' => $crawler->filter('h1')->first()->text(), 'og_title' => $crawler->filter('meta[property*="og:title"]')->first()->attr('content'), 'image' => $crawler->filter("figure > img")->first()->attr('src'), 'content' => $this->content, 'url' => $url, 'date' => Carbon::parse($date)->format("Y-m-d H:i:s"), 'guid' => basename($url), 'author' => $this->author, 'topics' => [ [ "name" => "ވަކި މަޢުލޫއެއް ނޭންގެ", "slug" => "no-specific-topic" ] ] ]; } }