2014-01-02 14:42:39 +04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* RssBridgeWikipediaEN
|
|
|
|
* Retrieve latest highlighted articles from Wikipedia in English.
|
2014-05-26 01:27:14 +04:00
|
|
|
* 2014-05-25
|
2014-01-02 14:42:39 +04:00
|
|
|
*
|
|
|
|
* @name Wikipedia EN "Today's Featured Article..."
|
2014-05-26 01:27:14 +04:00
|
|
|
* @homepage https://en.wikipedia.org/
|
2014-01-02 14:42:39 +04:00
|
|
|
* @description Returns the highlighted en.wikipedia.org article.
|
2014-05-21 21:44:14 +04:00
|
|
|
* @maintainer gsurrel
|
2014-01-02 14:42:39 +04:00
|
|
|
*/
|
|
|
|
class WikipediaENBridge extends BridgeAbstract{
|
|
|
|
|
|
|
|
public function collectData(array $param){
|
|
|
|
$html = '';
|
|
|
|
$host = 'http://en.wikipedia.org';
|
|
|
|
// If you want HTTPS access instead, uncomment the following line:
|
|
|
|
//$host = 'https://en.wikipedia.org';
|
|
|
|
$link = '/wiki/Main_Page';
|
|
|
|
|
|
|
|
$html = file_get_html($host.$link) or $this->returnError('Could not request Wikipedia EN.', 404);
|
|
|
|
|
|
|
|
$element = $html->find('div[id=mp-tfa]', 0);
|
|
|
|
// Clean the bottom of the featured article
|
|
|
|
$element->find('div', -1)->outertext = '';
|
|
|
|
$item = new \Item();
|
|
|
|
$item->uri = $host.$element->find('p', 0)->find('a', 0)->href;
|
|
|
|
$item->title = $element->find('p',0)->find('a',0)->title;
|
|
|
|
$item->content = str_replace('href="/', 'href="'.$host.'/', $element->innertext);
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName(){
|
|
|
|
return 'Wikipedia EN "Today\'s Featued Article"';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getURI(){
|
|
|
|
return 'https://en.wikipedia.org/wiki/Main_Page';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheDuration(){
|
|
|
|
return 3600*4; // 4 hours
|
|
|
|
}
|
|
|
|
}
|