WikipediaFRBridge.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * RssBridgeWikipediaFR
  4. * Retrieve latest highlighted articles from Wikipedia in French.
  5. * 2014-05-25
  6. *
  7. * @name Wikipedia FR "Lumière sur..."
  8. * @homepage https://fr.wikipedia.org/
  9. * @description Returns the highlighted fr.wikipedia.org article.
  10. * @maintainer gsurrel
  11. */
  12. class WikipediaFRBridge extends BridgeAbstract{
  13. public function collectData(array $param){
  14. $html = '';
  15. $host = 'http://fr.wikipedia.org';
  16. // If you want HTTPS access instead, uncomment the following line:
  17. //$host = 'https://fr.wikipedia.org';
  18. $link = '/wiki/Wikip%C3%A9dia:Accueil_principal';
  19. $html = file_get_html($host.$link) or $this->returnError('Could not request Wikipedia FR.', 404);
  20. $element = $html->find('div[id=accueil-lumieresur]', 0);
  21. $item = new \Item();
  22. $item->uri = $host.$element->find('p', 0)->find('a', 0)->href;
  23. $item->title = $element->find('p',0)->find('a',0)->title;
  24. $item->content = str_replace('href="/', 'href="'.$host.'/', $element->find('div[id=mf-lumieresur]', 0)->innertext);
  25. $this->items[] = $item;
  26. }
  27. public function getName(){
  28. return 'Wikipedia FR "Lumière sur..."';
  29. }
  30. public function getURI(){
  31. return 'https://fr.wikipedia.org/wiki/Wikip%C3%A9dia:Accueil_principal';
  32. }
  33. public function getCacheDuration(){
  34. return 3600*4; // 4 hours
  35. }
  36. }