forked from blallo/rss-bridge
Merge pull request #231 from teromene/master
Corrected CourrierInternationalBridge
This commit is contained in:
commit
084eb4c9f4
1 changed files with 25 additions and 28 deletions
|
@ -13,52 +13,49 @@ class CourrierInternationalBridge extends BridgeAbstract{
|
||||||
|
|
||||||
public function collectData(array $param){
|
public function collectData(array $param){
|
||||||
|
|
||||||
function fetchArticle($link) {
|
$html = '';
|
||||||
|
|
||||||
$page = file_get_html($link);
|
$html = file_get_html('http://www.courrierinternational.com/') or $this->returnError('Error.', 500);
|
||||||
|
|
||||||
$contenu = $page->find(".article-text")[0];
|
|
||||||
|
|
||||||
return strip_tags($contenu);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
$element = $html->find("article");
|
||||||
|
|
||||||
$html = '';
|
$article_count = 1;
|
||||||
|
|
||||||
$html = file_get_html('http://www.courrierinternational.com/article') or $this->returnError('Error.', 500);
|
foreach($element as $article) {
|
||||||
|
|
||||||
|
$item = new \Item();
|
||||||
|
|
||||||
|
$item->uri = $article->parent->getAttribute("href");
|
||||||
|
|
||||||
$element = $html->find(".type-normal");
|
if(strpos($item->uri, "http") === FALSE) {
|
||||||
|
$item->uri = "http://courrierinternational.fr/".$item->uri;
|
||||||
|
}
|
||||||
|
|
||||||
$article_count = 1;
|
$page = file_get_html($item->uri);
|
||||||
|
|
||||||
foreach($element as $article) {
|
$cleaner = new HTMLSanitizer();
|
||||||
|
|
||||||
$item = new \Item();
|
$item->content = $cleaner->sanitize($page->find("div.article-text")[0]);
|
||||||
|
$item->title = strip_tags($article->find(".title")[0]);
|
||||||
|
|
||||||
$item->uri = "http://www.courrierinternational.com".$article->find("a")[0]->getAttribute("href");
|
$dateTime = date_parse($page->find("time")[0]);
|
||||||
$item->content = fetchArticle("http://www.courrierinternational.com".$article->find("a")[0]->getAttribute("href"));
|
|
||||||
$item->title = strip_tags($article->find("h2")[0]);
|
|
||||||
|
|
||||||
$dateTime = date_parse($article->find("time")[0]);
|
$item->timestamp = mktime(
|
||||||
|
|
||||||
$item->timestamp = mktime(
|
|
||||||
$dateTime['hour'],
|
$dateTime['hour'],
|
||||||
$dateTime['minute'],
|
$dateTime['minute'],
|
||||||
$dateTime['second'],
|
$dateTime['second'],
|
||||||
$dateTime['month'],
|
$dateTime['month'],
|
||||||
$dateTime['day'],
|
$dateTime['day'],
|
||||||
$dateTime['year']
|
$dateTime['year']
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
$article_count ++;
|
$article_count ++;
|
||||||
if($article_count > 5) break;
|
if($article_count > 5) break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue