2014-07-22 16:55:22 +04:00
|
|
|
<?php
|
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
class MondeDiploBridge extends BridgeAbstract
|
|
|
|
{
|
|
|
|
const MAINTAINER = 'Pitchoule';
|
|
|
|
const NAME = 'Monde Diplomatique';
|
|
|
|
const URI = 'https://www.monde-diplomatique.fr';
|
|
|
|
const CACHE_TIMEOUT = 21600; //6h
|
|
|
|
const DESCRIPTION = 'Returns most recent results from MondeDiplo.';
|
2015-11-04 12:47:21 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
private function cleanText($text)
|
|
|
|
{
|
|
|
|
return trim(str_replace([' ', ' '], ' ', $text));
|
|
|
|
}
|
2020-08-27 08:28:59 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
|
|
|
$html = getSimpleHTMLDOM(self::URI);
|
2016-08-03 22:08:35 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
foreach ($html->find('div.unarticle') as $article) {
|
|
|
|
$element = $article->parent();
|
|
|
|
$title = $element->find('h3', 0)->plaintext;
|
|
|
|
$datesAuteurs = $element->find('div.dates_auteurs', 0)->plaintext;
|
|
|
|
$item = [];
|
|
|
|
$item['uri'] = urljoin(self::URI, $element->href);
|
|
|
|
$item['title'] = $this->cleanText($title) . ' - ' . $this->cleanText($datesAuteurs);
|
|
|
|
$item['content'] = $this->cleanText(str_replace([$title, $datesAuteurs], '', $element->plaintext));
|
2017-02-11 18:16:56 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
2014-07-22 16:55:22 +04:00
|
|
|
}
|