2015-09-01 19:45:39 +02:00
|
|
|
<?php
|
|
|
|
class CourrierInternationalBridge extends BridgeAbstract{
|
|
|
|
|
2015-11-03 23:28:44 +01:00
|
|
|
public function loadMetadatas() {
|
|
|
|
|
|
|
|
$this->maintainer = "teromene";
|
2016-08-09 20:01:21 +02:00
|
|
|
$this->name = "Courrier International Bridge";
|
2015-11-03 23:28:44 +01:00
|
|
|
$this->uri = "http://CourrierInternational.fr/";
|
|
|
|
$this->description = "Courrier International bridge";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-08-25 01:24:53 +02:00
|
|
|
public function collectData(){
|
2016-07-08 19:06:35 +02:00
|
|
|
|
2016-03-02 12:49:27 +01:00
|
|
|
$html = '';
|
2015-09-01 19:45:39 +02:00
|
|
|
|
2016-07-08 19:06:35 +02:00
|
|
|
$html = $this->getSimpleHTMLDOM('http://www.courrierinternational.com/') or $this->returnServerError('Error.');
|
|
|
|
|
|
|
|
|
2015-09-01 19:45:39 +02:00
|
|
|
|
2016-03-02 12:49:27 +01:00
|
|
|
$element = $html->find("article");
|
2015-09-01 19:45:39 +02:00
|
|
|
|
2016-07-08 19:06:35 +02:00
|
|
|
$article_count = 1;
|
2015-09-01 19:45:39 +02:00
|
|
|
|
2016-03-02 12:49:27 +01:00
|
|
|
foreach($element as $article) {
|
2016-07-08 19:06:35 +02:00
|
|
|
|
2016-08-22 18:55:59 +02:00
|
|
|
$item = array();
|
2016-07-08 19:06:35 +02:00
|
|
|
|
2016-08-22 18:55:59 +02:00
|
|
|
$item['uri'] = $article->parent->getAttribute("href");
|
2016-03-02 12:49:27 +01:00
|
|
|
|
2016-08-22 18:55:59 +02:00
|
|
|
if(strpos($item['uri'], "http") === FALSE) {
|
|
|
|
$item['uri'] = "http://courrierinternational.fr/".$item['uri'];
|
2016-03-02 12:49:27 +01:00
|
|
|
}
|
2016-07-08 19:06:35 +02:00
|
|
|
|
2016-08-22 18:55:59 +02:00
|
|
|
$page = $this->getSimpleHTMLDOM($item['uri']);
|
2015-09-01 19:45:39 +02:00
|
|
|
|
2016-03-02 12:49:27 +01:00
|
|
|
$cleaner = new HTMLSanitizer();
|
2016-07-08 19:06:35 +02:00
|
|
|
|
2016-08-22 18:55:59 +02:00
|
|
|
$item['content'] = $cleaner->sanitize($page->find("div.article-text")[0]);
|
|
|
|
$item['title'] = strip_tags($article->find(".title")[0]);
|
2015-09-01 19:45:39 +02:00
|
|
|
|
2016-03-02 12:49:27 +01:00
|
|
|
$dateTime = date_parse($page->find("time")[0]);
|
|
|
|
|
2016-08-22 18:55:59 +02:00
|
|
|
$item['timestamp'] = mktime(
|
2016-07-08 19:06:35 +02:00
|
|
|
$dateTime['hour'],
|
|
|
|
$dateTime['minute'],
|
|
|
|
$dateTime['second'],
|
|
|
|
$dateTime['month'],
|
|
|
|
$dateTime['day'],
|
2015-09-01 19:45:39 +02:00
|
|
|
$dateTime['year']
|
2016-03-02 12:49:27 +01:00
|
|
|
);
|
2016-07-08 19:06:35 +02:00
|
|
|
|
2016-03-02 12:49:27 +01:00
|
|
|
$this->items[] = $item;
|
|
|
|
$article_count ++;
|
|
|
|
if($article_count > 5) break;
|
2016-07-08 19:06:35 +02:00
|
|
|
|
2016-03-02 12:49:27 +01:00
|
|
|
}
|
2015-09-01 19:45:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheDuration(){
|
|
|
|
return 300; // 5 minutes
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|