forked from RSS-Bridge/rss-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NiceMatinBridge.php
32 lines (26 loc) · 912 Bytes
/
NiceMatinBridge.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 NiceMatinBridge extends FeedExpander {
const MAINTAINER = 'pit-fgfjiudghdf';
const NAME = 'NiceMatin';
const URI = 'http://www.nicematin.com/';
const DESCRIPTION = 'Returns the 10 newest posts from NiceMatin (full text)';
public function collectData(){
$this->collectExpandableDatas(self::URI . 'derniere-minute/rss', 10);
}
protected function parseItem($newsItem){
$item = parent::parseItem($newsItem);
$item['content'] = $this->extractContent($item['uri']);
return $item;
}
private function extractContent($url){
$html = getSimpleHTMLDOMCached($url);
if(!$html)
return 'Could not acquire content from url: ' . $url . '!';
$content = $html->find('article', 0);
if(!$content)
return 'Could not find \'section\'!';
$text = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $content->innertext);
$text = strip_tags($text, '<p><a><img>');
return $text;
}
}