Rss-Bridge/bridges/CourrierInternationalBridge.php
Pierre Mazière de1b39c8e5 [core + bridges] get rid of loadMetadata
if a bridge needs to modify some of the data that were initialized
there, ::__construct() should be used instead.

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
2016-08-28 13:05:03 +02:00

65 lines
1.5 KiB
PHP

<?php
class CourrierInternationalBridge extends BridgeAbstract{
public $maintainer = "teromene";
public $name = "Courrier International Bridge";
public $uri = "http://CourrierInternational.fr/";
public $description = "Courrier International bridge";
public function collectData(){
$html = '';
$html = $this->getSimpleHTMLDOM('http://www.courrierinternational.com/') 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'] = "http://courrierinternational.fr/".$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;
}
}
public function getCacheDuration(){
return 300; // 5 minutes
}
}
?>