MsnMondeBridge.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * RssBridgeMsnMonde
  4. * Returns the 10 newest posts from MSN Actualités (full text)
  5. *
  6. * @name MSN Actu Monde
  7. * @homepage http://www.msn.com/fr-fr/actualite/monde
  8. * @description Returns the 10 newest posts from MSN Actualités (full text)
  9. * @maintainer kranack
  10. * @update 2015-01-30
  11. */
  12. class MsnMondeBridge extends BridgeAbstract{
  13. public function collectData(array $param){
  14. function MsnMondeExtractContent($url, &$item) {
  15. $html2 = file_get_html($url);
  16. $item->content = $html2->find('#content', 0)->find('article', 0)->find('section', 0)->plaintext;
  17. $item->timestamp = strtotime($html2->find('.authorinfo-txt', 0)->find('time', 0)->datetime);
  18. }
  19. $html = file_get_html('http://www.msn.com/fr-fr/actualite/monde') or $this->returnError('Could not request MsnMonde.', 404);
  20. $limit = 0;
  21. foreach($html->find('.smalla') as $article) {
  22. if($limit < 10) {
  23. $item = new \Item();
  24. $item->title = utf8_decode($article->find('h4', 0)->innertext);
  25. $item->uri = "http://www.msn.com" . utf8_decode($article->find('a', 0)->href);
  26. MsnMondeExtractContent($item->uri, $item);
  27. $this->items[] = $item;
  28. $limit++;
  29. }
  30. }
  31. }
  32. public function getName(){
  33. return 'MSN Actu Monde';
  34. }
  35. public function getURI(){
  36. return 'http://www.msn.com/fr-fr/actualite/monde';
  37. }
  38. public function getCacheDuration(){
  39. return 3600; // 1 hour
  40. }
  41. }