rss-bridge/bridges/NiceMatinBridge.php

40 lines
1 KiB
PHP
Raw Normal View History

<?php
class NiceMatinBridge extends FeedExpander
{
const MAINTAINER = 'pit-fgfjiudghdf';
const NAME = 'NiceMatin';
const URI = 'https://www.nicematin.com/';
const DESCRIPTION = 'Returns the 10 newest posts from NiceMatin (full text)';
2015-11-04 12:47:21 +03:00
public function collectData()
{
$this->collectExpandableDatas(self::URI . 'derniere-minute/rss', 10);
}
protected function parseItem($item)
{
$item = parent::parseItem($item);
$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;
}
2016-08-03 23:39:03 +03:00
}