client = new Client(); } /** * extract. * * @param mixed $url * @param mixed $date * @param mixed $guid * * @return array */ public function extract($url) { $this->guid = str_replace('https://thiladhun.com/', '', $url); $crawler = $this->client->request('GET', $url); $crawler->filter('h1')->each(function ($node) { $this->title = $node->text(); }); $crawler->filter('div.single-body.entry-content.typography-copy p')->each(function ($node) { $this->content[] = preg_replace("/[a-zA-Z]/", "", $node->text());; }); $crawler->filter('div[class*="entry-thumb single-entry-thumb"] img')->each(function ($node) { $this->image = $node->attr('src'); }); $crawler->filter('a[class*="entry-author__name"]')->each(function ($node) { $this->author = $node->text(); }); return [ 'source' => 'Thiladhun News', 'title' => $this->title, 'og_title' => str_replace(" | Thiladhun", "", $crawler->filter('title')->first()->text('content')), 'image' => $this->image, 'content' => $this->content, 'date' => $crawler->filter('.entry-meta time')->attr('datetime'), 'url' => $url, 'author' => $this->author, 'guid' => $this->guid, 'topics' => [ [ "name" => "ވަކި މަޢުލޫއެއް ނޭންގެ", "slug" => "no-specific-topic" ] ] ]; } }