Example #1
0
 public function collectData(array $param)
 {
     $html = '';
     if (isset($param['q'])) {
         /* keyword search mode */
         $this->request = str_replace(" ", "-", trim($param['q']));
         $html = file_get_html('http://www.cpasbien.pw/recherche/' . urlencode($this->request) . '.html') or $this->returnError('No results for this query.', 404);
     } else {
         $this->returnError('You must specify a keyword (?q=...).', 400);
     }
     foreach ($html->find('#gauche', 0)->find('div') as $episode) {
         if ($episode->getAttribute('class') == 'ligne0' || $episode->getAttribute('class') == 'ligne1') {
             $htmlepisode = content_get_html($this->get_cached($episode->find('a', 0)->getAttribute('href')));
             $item = new \Item();
             $item->name = $episode->find('a', 0)->text();
             $item->title = $episode->find('a', 0)->text();
             $item->timestamp = $this->get_cached_time($episode->find('a', 0)->getAttribute('href'));
             $textefiche = $htmlepisode->find('#textefiche', 0)->find('p', 1);
             if (isset($textefiche)) {
                 $item->content = $textefiche->text();
             } else {
                 $item->content = $htmlepisode->find('#textefiche', 0)->find('p', 0)->text();
             }
             $item->id = $episode->find('a', 0)->getAttribute('href');
             $item->uri = $this->getURI() . $htmlepisode->find('#telecharger', 0)->getAttribute('href');
             $item->thumbnailUri = $htmlepisode->find('#bigcover', 0)->find('img', 0)->getAttribute('src');
             $this->items[] = $item;
         }
     }
 }
Example #2
0
 private function getDate($url)
 {
     if (!$this->isLoggedIn()) {
         $this->setError(true);
         return;
     }
     curl_setopt($this->getCurl(), CURLOPT_URL, $url);
     curl_setopt($this->getCurl(), CURLOPT_POST, false);
     curl_setopt($this->getCurl(), CURLOPT_POSTFIELDS, "");
     $response = curl_exec($this->getCurl());
     if (curl_error($this->getCurl())) {
         $this->setError(true);
         return;
     }
     if (curl_getinfo($this->getCurl(), CURLINFO_HTTP_CODE) == 404) {
         $this->setError(true);
         return;
     }
     $html = content_get_html($response);
     $info = $html->find('.mon_title', 0);
     $time = explode(" ", $info->plaintext)[0];
     return $time;
 }