WikipediaFRBridge.php 1.3 KB

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