-
Notifications
You must be signed in to change notification settings - Fork 1k
/
MondeDiploBridge.php
32 lines (27 loc) · 1.06 KB
/
MondeDiploBridge.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
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.';
private function cleanText($text)
{
return trim(str_replace([' ', ' '], ' ', $text));
}
public function collectData()
{
$html = getSimpleHTMLDOM(self::URI);
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));
$this->items[] = $item;
}
}
}