private function saveIcon() { try { $urlData = parse_url($this->url); $siteUrl = $urlData['scheme'] . '://' . $urlData['host']; $html = (new Client())->createRequest()->setUrl($siteUrl)->send()->getContent(); $saw = new \nokogiri($html); $icons = $saw->get('link[rel="icon"]')->toArray(); $iconUrl = null; if ($icons) { $iconUrl = $icons[0]['href']; $iconUrl = strstr($iconUrl, 'http') === false ? $siteUrl . $iconUrl : $iconUrl; } else { $iconUrl = $siteUrl . '/favicon.ico'; } $response = (new Client())->createRequest()->setUrl($iconUrl)->send(); if ($response->isOk) { file_put_contents(FeedModel::getIconsPath() . '/' . $this->id . '.' . pathinfo($iconUrl, PATHINFO_EXTENSION), $response->getContent()); } } catch (\Exception $e) { } return true; }