Example #1
0
 /**
  * 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;
 }
Example #2
0
 /**
  * Set config object
  *
  * @access public
  * @param  \PicoFeed\Config\Config  $config   Config instance
  * @return \PicoFeed\Client\Client
  */
 public function setConfig($config)
 {
     if ($config !== null) {
         $this->setTimeout($config->getGrabberTimeout());
         $this->setUserAgent($config->getGrabberUserAgent());
         $this->setMaxRedirections($config->getMaxRedirections());
         $this->setMaxBodySize($config->getMaxBodySize());
         $this->setProxyHostname($config->getProxyHostname());
         $this->setProxyPort($config->getProxyPort());
         $this->setProxyUsername($config->getProxyUsername());
         $this->setProxyPassword($config->getProxyPassword());
     }
     return $this;
 }