forked from RSS-Bridge/rss-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DauphineLibereBridge.php
56 lines (49 loc) · 1.45 KB
/
DauphineLibereBridge.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
class DauphineLibereBridge extends FeedExpander {
const MAINTAINER = 'qwertygc';
const NAME = 'Dauphine Bridge';
const URI = 'http://www.ledauphine.com/';
const CACHE_TIMEOUT = 7200; // 2h
const DESCRIPTION = 'Returns the newest articles.';
const PARAMETERS = array( array(
'u' => array(
'name' => 'Catégorie de l\'article',
'type' => 'list',
'values' => array(
'À la une' => '',
'France Monde' => 'france-monde',
'Faits Divers' => 'faits-divers',
'Économie et Finance' => 'economie-et-finance',
'Politique' => 'politique',
'Sport' => 'sport',
'Ain' => 'ain',
'Alpes-de-Haute-Provence' => 'haute-provence',
'Hautes-Alpes' => 'hautes-alpes',
'Ardèche' => 'ardeche',
'Drôme' => 'drome',
'Isère Sud' => 'isere-sud',
'Savoie' => 'savoie',
'Haute-Savoie' => 'haute-savoie',
'Vaucluse' => 'vaucluse'
)
)
));
public function collectData(){
$url = self::URI . 'rss';
if(empty($this->getInput('u'))) {
$url = self::URI . $this->getInput('u') . '/rss';
}
$this->collectExpandableDatas($url, 10);
}
protected function parseItem($newsItem){
$item = parent::parseItem($newsItem);
$item['content'] = $this->extractContent($item['uri']);
return $item;
}
private function extractContent($url){
$html2 = getSimpleHTMLDOMCached($url);
$text = $html2->find('div.column', 0)->innertext;
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
return $text;
}
}