MondeDiploBridge.php 2.2 KB

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