rss-bridge/bridges/CourrierInternationalBridge.php
Pierre Mazière 235c985901 [BridgeAbstract] replace getCacheDuration method by CACHE_TIMEOUT class constant
Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
2016-09-25 17:04:28 +02:00

58 lines
1.4 KiB
PHP

<?php
class CourrierInternationalBridge extends BridgeAbstract{
const MAINTAINER = "teromene";
const NAME = "Courrier International Bridge";
const URI = "http://CourrierInternational.com/";
const CACHE_TIMEOUT = 300; // 5 min
const DESCRIPTION = "Courrier International bridge";
public function collectData(){
$html = $this->getSimpleHTMLDOM(self::URI)
or $this->returnServerError('Error.');
$element = $html->find("article");
$article_count = 1;
foreach($element as $article) {
$item = array();
$item['uri'] = $article->parent->getAttribute("href");
if(strpos($item['uri'], "http") === FALSE) {
$item['uri'] = self::URI.$item['uri'];
}
$page = $this->getSimpleHTMLDOM($item['uri']);
$cleaner = new HTMLSanitizer();
$item['content'] = $cleaner->sanitize($page->find("div.article-text")[0]);
$item['title'] = strip_tags($article->find(".title")[0]);
$dateTime = date_parse($page->find("time")[0]);
$item['timestamp'] = mktime(
$dateTime['hour'],
$dateTime['minute'],
$dateTime['second'],
$dateTime['month'],
$dateTime['day'],
$dateTime['year']
);
$this->items[] = $item;
$article_count ++;
if($article_count > 5) break;
}
}
}
?>