rss-bridge/bridges/CourrierInternationalBridge.php

78 lines
1.8 KiB
PHP
Raw Normal View History

<?php
class CourrierInternationalBridge extends BridgeAbstract{
public function loadMetadatas() {
$this->maintainer = "teromene";
$this->name = "CourrierInternational";
$this->uri = "http://CourrierInternational.fr/";
$this->description = "Courrier International bridge";
$this->update = "01/09/2015";
}
public function collectData(array $param){
2016-03-02 12:49:27 +01:00
$html = '';
$html = $this->file_get_html('http://www.courrierinternational.com/') or $this->returnError('Error.', 500);
2016-03-02 12:49:27 +01:00
$element = $html->find("article");
2016-03-02 12:49:27 +01:00
$article_count = 1;
2016-03-02 12:49:27 +01:00
foreach($element as $article) {
2016-03-02 12:49:27 +01:00
$item = new \Item();
2016-03-02 12:49:27 +01:00
$item->uri = $article->parent->getAttribute("href");
if(strpos($item->uri, "http") === FALSE) {
$item->uri = "http://courrierinternational.fr/".$item->uri;
}
$page = $this->file_get_html($item->uri);
2016-03-02 12:49:27 +01:00
$cleaner = new HTMLSanitizer();
$item->content = $cleaner->sanitize($page->find("div.article-text")[0]);
$item->title = strip_tags($article->find(".title")[0]);
2016-03-02 12:49:27 +01:00
$dateTime = date_parse($page->find("time")[0]);
$item->timestamp = mktime(
$dateTime['hour'],
$dateTime['minute'],
$dateTime['second'],
$dateTime['month'],
$dateTime['day'],
$dateTime['year']
2016-03-02 12:49:27 +01:00
);
2016-03-02 12:49:27 +01:00
$this->items[] = $item;
$article_count ++;
if($article_count > 5) break;
2016-03-02 12:49:27 +01:00
}
}
public function getName(){
return 'Courrier International Bridge';
}
public function getURI(){
return 'http://courrierinternational.com';
}
public function getCacheDuration(){
return 300; // 5 minutes
}
}
?>