1
0

WikipediaEOBridge.php 1.3 KB

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