NiceMatinBridge.php 912 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. class NiceMatinBridge extends FeedExpander {
  3. const MAINTAINER = 'pit-fgfjiudghdf';
  4. const NAME = 'NiceMatin';
  5. const URI = 'http://www.nicematin.com/';
  6. const DESCRIPTION = 'Returns the 10 newest posts from NiceMatin (full text)';
  7. public function collectData(){
  8. $this->collectExpandableDatas(self::URI . 'derniere-minute/rss', 10);
  9. }
  10. protected function parseItem($newsItem){
  11. $item = parent::parseItem($newsItem);
  12. $item['content'] = $this->extractContent($item['uri']);
  13. return $item;
  14. }
  15. private function extractContent($url){
  16. $html = getSimpleHTMLDOMCached($url);
  17. if(!$html)
  18. return 'Could not acquire content from url: ' . $url . '!';
  19. $content = $html->find('article', 0);
  20. if(!$content)
  21. return 'Could not find \'section\'!';
  22. $text = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $content->innertext);
  23. $text = strip_tags($text, '<p><a><img>');
  24. return $text;
  25. }
  26. }