WeLiveSecurityBridge.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. class WeLiveSecurityBridge extends FeedExpander {
  3. const MAINTAINER = 'ORelio';
  4. const NAME = 'We Live Security';
  5. const URI = 'http://www.welivesecurity.com/';
  6. const DESCRIPTION = 'Returns the newest articles.';
  7. private function StripWithDelimiters($string, $start, $end) {
  8. while (strpos($string, $start) !== false) {
  9. $section_to_remove = substr($string, strpos($string, $start));
  10. $section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
  11. $string = str_replace($section_to_remove, '', $string);
  12. } return $string;
  13. }
  14. protected function parseItem($item){
  15. $item = parent::parseItem($item);
  16. $article_html = getSimpleHTMLDOMCached($item['uri']);
  17. if(!$article_html){
  18. $item['content'] .= '<p>Could not request '.$this->getName().': '.$item['uri'].'</p>';
  19. return $item;
  20. }
  21. $article_content = $article_html->find('div.wlistingsingletext', 0)->innertext;
  22. $article_content = $this->StripWithDelimiters($article_content, '<script', '</script>');
  23. $article_content = '<p><b>'.$item['content'].'</b></p>'
  24. .trim($article_content);
  25. $item['content'] = $article_content;
  26. return $item;
  27. }
  28. public function collectData(){
  29. $feed = static::URI.'feed/';
  30. $this->collectExpandableDatas($feed);
  31. }
  32. }