WikipediaEOBridge.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * RssBridgeWikipediaEO
  4. * Retrieve latest highlighted articles from Wikipedia in Esperanto.
  5. *
  6. * @name Wikipedia EO "Artikolo de la semajno"
  7. * @description Returns the highlighted eo.wikipedia.org article.
  8. * @maintainer gsurrel
  9. */
  10. class WikipediaEOBridge extends BridgeAbstract{
  11. public function collectData(array $param){
  12. $html = '';
  13. $host = 'http://eo.wikipedia.org';
  14. // If you want HTTPS access instead, uncomment the following line:
  15. //$host = 'https://eo.wikipedia.org';
  16. $link = '/wiki/Vikipedio:%C4%88efpa%C4%9Do';
  17. $html = file_get_html($host.$link) or $this->returnError('Could not request Wikipedia EO.', 404);
  18. $element = $html->find('div[id=mf-tfa]', 0);
  19. // Link to article
  20. $link = $element->find('p', -2)->find('a', 0);
  21. $item = new \Item();
  22. $item->uri = $host.$link->href;
  23. $item->title = $link->title;
  24. $item->content = str_replace('href="/', 'href="'.$host.'/', $element->innertext);
  25. $this->items[] = $item;
  26. }
  27. public function getName(){
  28. return 'Wikipedia EO "Artikolo de la semajno"';
  29. }
  30. public function getURI(){
  31. return 'https://eo.wikipedia.org/wiki/Vikipedio:%C4%88efpa%C4%9Do';
  32. }
  33. public function getCacheDuration(){
  34. return 3600*12; // 12 hours
  35. }
  36. }