WikipediaEOBridge.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. class WikipediaEOBridge extends BridgeAbstract{
  3. public function loadMetadatas() {
  4. $this->maintainer = "gsurrel";
  5. $this->name = "Wikipedia EO 'Artikolo de la semajno'";
  6. $this->uri = "https://eo.wikipedia.org/";
  7. $this->description = "Returns the highlighted eo.wikipedia.org article.";
  8. $this->update = "2014-05-25";
  9. }
  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 = $this->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. }