Rss-Bridge/bridges/NiceMatinBridge.php

35 lines
1 KiB
PHP
Raw Normal View History

<?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)";
2015-11-04 10:47:21 +01:00
public function collectData(){
$this->collectExpandableDatas(self::URI . 'derniere-minute/rss', 10);
}
protected function parseItem($newsItem){
$item = $this->parseRSS_2_0_Item($newsItem);
$item['content'] = $this->NiceMatinExtractContent($item['uri']);
return $item;
}
private function NiceMatinExtractContent($url) {
if($this->get_cached_time($url) <= strtotime('-24 hours'))
$this->remove_from_cache($url);
$html = $this->get_cached($url);
2016-08-03 22:39:03 +02:00
if(!$html)
return 'Could not acquire content from url: ' . $url . '!';
2016-08-03 22:39:03 +02:00
$content = $html->find('article', 0);
if(!$content)
return 'Could not find \'section\'!';
2016-08-03 22:39:03 +02:00
$text = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $content->innertext);
$text = strip_tags($text, '<p><a><img>');
return $text;
2015-11-04 10:47:21 +01:00
}
2016-08-03 22:39:03 +02:00
}