MsnMondeBridge.php 1.5 KB

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