MondeDiploBridge.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * RssBridgeMondeDiplo
  4. * Search MondeDiplo for most recent pages.
  5. * Returns the most recent links in results.
  6. * 2014-07-22
  7. *
  8. * @name MondeDiplo
  9. * @homepage http://www.monde-diplomatique.fr
  10. * @description Returns most recent results from MondeDiplo.
  11. * @maintainer Pitchoule
  12. */
  13. class MondeDiploBridge extends BridgeAbstract{
  14. public function collectData(array $param){
  15. $link = 'http://www.monde-diplomatique.fr';
  16. $html = file_get_html($link) or $this->returnError('Could not request MondeDiplo. for : ' . $link , 404);
  17. foreach($html->find('div.laune') as $element) {
  18. $item = new Item();
  19. $item->uri = 'http://www.monde-diplomatique.fr'.$element->find('a', 0)->href;
  20. $item->title = $element->find('h3', 0)->plaintext;
  21. $item->content = $element->find('div.dates_auteurs', 0)->plaintext. '<br>' .strstr($element->find('div', 0)->plaintext, $element->find('div.dates_auteurs', 0)->plaintext, true);
  22. $this->items[] = $item;
  23. }
  24. $liste = $html->find('div.listes', 0); // First list
  25. foreach ($liste->find('li') as $e) {
  26. $item = new Item();
  27. $item->uri = 'http://www.monde-diplomatique.fr' . $e->find('a', 0)->href;
  28. $item->title = $e->find('a', 0)->plaintext;
  29. $item->content = $e->find('div.dates_auteurs', 0)->plaintext;
  30. $this->items[] = $item;
  31. }
  32. foreach($html->find('div.liste ul li') as $element) {
  33. if ($element->getAttribute('class') != 'intrapub') {
  34. $item = new Item();
  35. $item->uri = 'http://www.monde-diplomatique.fr'.$element->find('a', 0)->href;
  36. $item->title = $element->find('h3', 0)->plaintext;
  37. $item->content = $element->find('div.dates_auteurs', 0)->plaintext . ' <br> ' . $element->find('div.intro', 0)->plaintext;
  38. $this->items[] = $item;
  39. }
  40. }
  41. }
  42. public function getName(){
  43. return 'Monde Diplomatique';
  44. }
  45. public function getURI(){
  46. return 'http://www.monde-diplomatique.fr';
  47. }
  48. public function getCacheDuration(){
  49. return 21600; // 6 hours
  50. }
  51. }