MsnMondeBridge.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. class MsnMondeBridge extends BridgeAbstract {
  3. const MAINTAINER = 'kranack';
  4. const NAME = 'MSN Actu Monde';
  5. const URI = 'http://www.msn.com/';
  6. const DESCRIPTION = 'Returns the 10 newest posts from MSN Actualités (full text)';
  7. public function getURI(){
  8. return self::URI . 'fr-fr/actualite/monde';
  9. }
  10. private function msnMondeExtractContent($url, &$item){
  11. $html2 = getSimpleHTMLDOM($url);
  12. $item['content'] = $html2->find('#content', 0)->find('article', 0)->find('section', 0)->plaintext;
  13. $item['timestamp'] = strtotime($html2->find('.authorinfo-txt', 0)->find('time', 0)->datetime);
  14. }
  15. public function collectData(){
  16. $html = getSimpleHTMLDOM($this->getURI())
  17. or returnServerError('Could not request MsnMonde.');
  18. $limit = 0;
  19. foreach($html->find('.smalla') as $article) {
  20. if($limit < 10) {
  21. $item = array();
  22. $item['title'] = utf8_decode($article->find('h4', 0)->innertext);
  23. $item['uri'] = self::URI . utf8_decode($article->find('a', 0)->href);
  24. $this->msnMondeExtractContent($item['uri'], $item);
  25. $this->items[] = $item;
  26. $limit++;
  27. }
  28. }
  29. }
  30. }