2014-05-26 21:45:10 +04:00
|
|
|
<?php
|
2016-09-05 19:43:56 +03:00
|
|
|
class NiceMatinBridge extends FeedExpander {
|
2014-05-26 21:45:10 +04:00
|
|
|
|
2016-08-30 12:23:55 +03:00
|
|
|
const MAINTAINER = "pit-fgfjiudghdf";
|
|
|
|
const NAME = "NiceMatin";
|
|
|
|
const URI = "http://www.nicematin.com/";
|
|
|
|
const DESCRIPTION = "Returns the 10 newest posts from NiceMatin (full text)";
|
2015-11-04 12:47:21 +03:00
|
|
|
|
2016-09-05 19:43:56 +03:00
|
|
|
public function collectData(){
|
2016-09-05 21:26:45 +03:00
|
|
|
$this->collectExpandableDatas(self::URI . 'derniere-minute/rss', 10);
|
2016-09-05 19:43:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function parseItem($newsItem){
|
2016-09-12 11:42:27 +03:00
|
|
|
$item = parent::parseItem($newsItem);
|
2016-09-05 19:43:56 +03:00
|
|
|
$item['content'] = $this->NiceMatinExtractContent($item['uri']);
|
|
|
|
return $item;
|
|
|
|
}
|
|
|
|
|
2016-08-06 17:00:56 +03:00
|
|
|
private function NiceMatinExtractContent($url) {
|
2016-09-10 20:11:09 +03:00
|
|
|
$html = $this->getSimpleHTMLDOMCached($url);
|
2016-08-03 23:39:03 +03:00
|
|
|
if(!$html)
|
2016-08-29 15:03:17 +03:00
|
|
|
return 'Could not acquire content from url: ' . $url . '!';
|
2016-07-08 20:06:35 +03:00
|
|
|
|
2016-08-03 23:39:03 +03:00
|
|
|
$content = $html->find('article', 0);
|
|
|
|
if(!$content)
|
2016-08-29 15:03:17 +03:00
|
|
|
return 'Could not find \'section\'!';
|
2016-07-08 20:06:35 +03:00
|
|
|
|
2016-08-03 23:39:03 +03:00
|
|
|
$text = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $content->innertext);
|
|
|
|
$text = strip_tags($text, '<p><a><img>');
|
|
|
|
return $text;
|
2015-11-04 12:47:21 +03:00
|
|
|
}
|
2016-08-03 23:39:03 +03:00
|
|
|
}
|