1
0

WikipediaEOBridge.php 1.2 KB

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