1
0
Fork 0
forked from blallo/rss-bridge
rss-bridge/bridges/CourrierInternationalBridge.php

68 lines
1.6 KiB
PHP
Raw Normal View History

<?php
class CourrierInternationalBridge extends BridgeAbstract{
const MAINTAINER = "teromene";
const NAME = "Courrier International Bridge";
const URI = "http://CourrierInternational.com/";
const DESCRIPTION = "Courrier International bridge";
public function collectData(){
$html = $this->getSimpleHTMLDOM(self::URI)
or $this->returnServerError('Error.');
2016-03-02 12:49:27 +01:00
$element = $html->find("article");
$article_count = 1;
2016-03-02 12:49:27 +01:00
foreach($element as $article) {
$item = array();
$item['uri'] = $article->parent->getAttribute("href");
2016-03-02 12:49:27 +01:00
if(strpos($item['uri'], "http") === FALSE) {
$item['uri'] = self::URI.$item['uri'];
2016-03-02 12:49:27 +01:00
}
$page = $this->getSimpleHTMLDOMCached($item['uri']);
2016-03-02 12:49:27 +01:00
$cleaner = new HTMLSanitizer();
$content = $page->find('.article-text',0);
if(!$content){
$content = $page->find('.depeche-text',0);
}
$item['content'] = $cleaner->sanitize($content);
$item['title'] = strip_tags($article->find(".title",0));
$dateTime = date_parse($page->find("time",0));
2016-03-02 12:49:27 +01:00
$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 getCacheDuration(){
return 300; // 5 minutes
}
}
?>