2015-02-07 22:25:38 +03:00
|
|
|
<?php
|
|
|
|
class ZatazBridge extends BridgeAbstract {
|
|
|
|
|
2016-08-30 12:23:55 +03:00
|
|
|
const MAINTAINER = "aledeg";
|
|
|
|
const NAME = 'Zataz Magazine';
|
|
|
|
const URI = 'http://www.zataz.com';
|
|
|
|
const DESCRIPTION = "ZATAZ Magazine - S'informer, c'est déjà se sécuriser";
|
2015-11-05 14:20:11 +03:00
|
|
|
|
2016-08-25 02:24:53 +03:00
|
|
|
public function collectData(){
|
2016-08-30 12:23:55 +03:00
|
|
|
$html = $this->getSimpleHTMLDOM(self::URI) or $this->returnServerError('Could not request ' . self::URI);
|
2015-02-07 22:25:38 +03:00
|
|
|
|
|
|
|
$recent_posts = $html->find('#recent-posts-3', 0)->find('ul', 0)->find('li');
|
|
|
|
foreach ($recent_posts as $article) {
|
|
|
|
if (count($this->items) < 5) {
|
|
|
|
$uri = $article->find('a', 0)->href;
|
|
|
|
$this->items[] = $this->getDetails($uri);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getDetails($uri) {
|
2016-07-08 20:06:35 +03:00
|
|
|
$html = $this->getSimpleHTMLDOM($uri) or exit;
|
2015-02-07 22:25:38 +03:00
|
|
|
|
2016-08-22 19:55:59 +03:00
|
|
|
$item = array();
|
2015-02-07 22:25:38 +03:00
|
|
|
|
|
|
|
$article = $html->find('.gdl-blog-full', 0);
|
2016-08-22 19:55:59 +03:00
|
|
|
$item['uri'] = $uri;
|
|
|
|
$item['title'] = $article->find('.blog-title', 0)->find('a', 0)->innertext;
|
|
|
|
$item['content'] = $article->find('.blog-content', 0)->innertext;
|
|
|
|
$item['timestamp'] = $this->getTimestampFromDate($article->find('.blog-date', 0)->find('a', 0)->href);
|
2015-02-07 22:25:38 +03:00
|
|
|
return $item;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getTimestampFromDate($uri) {
|
|
|
|
preg_match('/\d{4}\/\d{2}\/\d{2}/', $uri, $matches);
|
|
|
|
$date = new \DateTime($matches[0]);
|
|
|
|
return $date->format('U');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheDuration() {
|
|
|
|
return 7200; // 2h
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|