2015-09-01 20:45:39 +03:00
|
|
|
<?php
|
|
|
|
class CourrierInternationalBridge extends BridgeAbstract{
|
|
|
|
|
2016-08-27 22:03:26 +03:00
|
|
|
public $maintainer = "teromene";
|
|
|
|
public $name = "Courrier International Bridge";
|
2016-08-28 14:14:56 +03:00
|
|
|
public $uri = "http://CourrierInternational.com/";
|
2016-08-27 22:03:26 +03:00
|
|
|
public $description = "Courrier International bridge";
|
2015-11-04 01:28:44 +03:00
|
|
|
|
2016-08-25 02:24:53 +03:00
|
|
|
public function collectData(){
|
2016-07-08 20:06:35 +03:00
|
|
|
|
2016-08-28 14:14:56 +03:00
|
|
|
$html = $this->getSimpleHTMLDOM($this->uri)
|
|
|
|
or $this->returnServerError('Error.');
|
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-07-08 20:06:35 +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) {
|
2016-07-08 20:06:35 +03:00
|
|
|
|
2016-08-22 19:55:59 +03:00
|
|
|
$item = array();
|
2016-07-08 20:06:35 +03:00
|
|
|
|
2016-08-22 19:55:59 +03:00
|
|
|
$item['uri'] = $article->parent->getAttribute("href");
|
2016-03-02 14:49:27 +03:00
|
|
|
|
2016-08-22 19:55:59 +03:00
|
|
|
if(strpos($item['uri'], "http") === FALSE) {
|
2016-08-28 14:14:56 +03:00
|
|
|
$item['uri'] = $this->uri.$item['uri'];
|
2016-03-02 14:49:27 +03:00
|
|
|
}
|
2016-07-08 20:06:35 +03:00
|
|
|
|
2016-08-22 19:55:59 +03:00
|
|
|
$page = $this->getSimpleHTMLDOM($item['uri']);
|
2015-09-01 20:45:39 +03:00
|
|
|
|
2016-03-02 14:49:27 +03:00
|
|
|
$cleaner = new HTMLSanitizer();
|
2016-07-08 20:06:35 +03:00
|
|
|
|
2016-08-22 19:55:59 +03:00
|
|
|
$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]);
|
|
|
|
|
2016-08-22 19:55:59 +03:00
|
|
|
$item['timestamp'] = mktime(
|
2016-07-08 20:06:35 +03:00
|
|
|
$dateTime['hour'],
|
|
|
|
$dateTime['minute'],
|
|
|
|
$dateTime['second'],
|
|
|
|
$dateTime['month'],
|
|
|
|
$dateTime['day'],
|
2015-09-01 20:45:39 +03:00
|
|
|
$dateTime['year']
|
2016-03-02 14:49:27 +03:00
|
|
|
);
|
2016-07-08 20:06:35 +03:00
|
|
|
|
2016-03-02 14:49:27 +03:00
|
|
|
$this->items[] = $item;
|
|
|
|
$article_count ++;
|
|
|
|
if($article_count > 5) break;
|
2016-07-08 20:06:35 +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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|