/** * Download the HTML content. * * @return bool */ public function download() { if (!empty($this->url)) { // Clear everything $this->html = ''; $this->content = ''; $this->encoding = ''; try { $client = Client::getInstance(); $client->setConfig($this->config); $client->setTimeout($this->config->getGrabberTimeout()); $client->setUserAgent($this->config->getGrabberUserAgent()); $client->execute($this->url); $this->url = $client->getUrl(); $this->html = $client->getContent(); $this->encoding = $client->getEncoding(); return true; } catch (ClientException $e) { Logger::setMessage(get_called_class() . ': ' . $e->getMessage()); } } return false; }
/** * Download a feed (no discovery). * * @param string $url Feed url * @param string $last_modified Last modified HTTP header * @param string $etag Etag HTTP header * @param string $username HTTP basic auth username * @param string $password HTTP basic auth password * * @return \AsteFeed\Client\Client */ public function download($url, $last_modified = '', $etag = '', $username = '', $password = '') { $url = $this->prependScheme($url); return Client::getInstance()->setConfig($this->config)->setLastModified($last_modified)->setEtag($etag)->setUsername($username)->setPassword($password)->execute($url); }
/** * Download and check if a resource exists. * * @param string $url URL * * @return \AsteFeed\Client Client instance */ public function download($url) { $client = Client::getInstance(); $client->setConfig($this->config); Logger::setMessage(get_called_class() . ' Download => ' . $url); try { $client->execute($url); } catch (ClientException $e) { Logger::setMessage(get_called_class() . ' Download Failed => ' . $e->getMessage()); } return $client; }