Rss-Bridge/bridges/WikipediaEOBridge.php

45 lines
1.4 KiB
PHP
Raw Normal View History

2014-01-02 11:58:10 +01:00
<?php
class WikipediaEOBridge extends BridgeAbstract{
public function loadMetadatas() {
$this->maintainer = "gsurrel";
$this->name = "Wikipedia EO 'Artikolo de la semajno'";
$this->uri = "https://eo.wikipedia.org/";
$this->description = "Returns the highlighted eo.wikipedia.org article.";
$this->update = "2014-05-25";
}
2014-01-02 11:58:10 +01:00
public function collectData(array $param){
$html = '';
$host = 'http://eo.wikipedia.org';
// If you want HTTPS access instead, uncomment the following line:
//$host = 'https://eo.wikipedia.org';
$link = '/wiki/Vikipedio:%C4%88efpa%C4%9Do';
$html = $this->file_get_html($host.$link) or $this->returnError('Could not request Wikipedia EO.', 404);
2014-01-02 11:58:10 +01:00
2016-08-04 12:49:08 +02:00
$element = $html->find('div[id=mf-artikolo-de-la-semajno]', 0);
2014-01-02 11:58:10 +01:00
// Link to article
2016-08-04 12:49:08 +02:00
$link = $element->find('p', 3)->find('a', 0);
2014-01-02 11:58:10 +01:00
$item = new \Item();
$item->uri = $host.$link->href;
2016-08-04 12:49:08 +02:00
$item->title = $element->find('p',0)->find('i',0)->innertext;
2014-01-02 11:58:10 +01:00
$item->content = str_replace('href="/', 'href="'.$host.'/', $element->innertext);
$this->items[] = $item;
}
public function getName(){
return 'Wikipedia EO "Artikolo de la semajno"';
}
public function getURI(){
return 'https://eo.wikipedia.org/wiki/Vikipedio:%C4%88efpa%C4%9Do';
}
public function getCacheDuration(){
return 3600*12; // 12 hours
}
}