Exemple #1
0
 /**
  * Download a feed
  *
  * @access public
  * @param  string  $url            Feed content
  * @param  string  $last_modified  Last modified HTTP header
  * @param  string  $etag           Etag HTTP header
  * @return \PicoFeed\Client
  */
 public function download($url, $last_modified = '', $etag = '')
 {
     if (strpos($url, 'http') !== 0) {
         $url = 'http://' . $url;
     }
     $client = Client::getInstance();
     $client->setTimeout($this->config->getClientTimeout())->setUserAgent($this->config->getClientUserAgent())->setMaxRedirections($this->config->getMaxRedirections())->setMaxBodySize($this->config->getMaxBodySize())->setProxyHostname($this->config->getProxyHostname())->setProxyPort($this->config->getProxyPort())->setProxyUsername($this->config->getProxyUsername())->setProxyPassword($this->config->getProxyPassword())->setLastModified($last_modified)->setEtag($etag);
     if ($client->execute($url)) {
         $this->content = $client->getContent();
         $this->url = $client->getUrl();
         $this->encoding = $client->getEncoding();
     }
     return $client;
 }
Exemple #2
0
 /**
  * Download the HTML content
  *
  * @access public
  * @return HTML content
  */
 public function download()
 {
     $client = Client::getInstance();
     if ($this->config !== null) {
         $client->setTimeout($this->config->getGrabberTimeout())->setUserAgent($this->config->getGrabberUserAgent())->setMaxRedirections($this->config->getMaxRedirections())->setMaxBodySize($this->config->getMaxBodySize())->setProxyHostname($this->config->getProxyHostname())->setProxyPort($this->config->getProxyPort())->setProxyUsername($this->config->getProxyUsername())->setProxyPassword($this->config->getProxyPassword());
     }
     $client->execute($this->url);
     $this->html = $client->getContent();
     $this->encoding = $client->getEncoding();
     return $this->html;
 }
Exemple #3
0
 /**
  * Set config object
  *
  * @access public
  * @param  \PicoFeed\Config  $config   Config instance
  * @return \PicoFeed\Client
  */
 public function setConfig($config)
 {
     $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;
 }