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