2014-01-02 14:26:15 +04:00
|
|
|
<?php
|
|
|
|
class WikipediaFRBridge extends BridgeAbstract{
|
|
|
|
|
2015-11-05 14:20:11 +03:00
|
|
|
public function loadMetadatas() {
|
|
|
|
|
|
|
|
$this->maintainer = "gsurrel";
|
|
|
|
$this->name = "Wikipedia FR 'Lumière sur...'";
|
|
|
|
$this->uri = "https://fr.wikipedia.org/";
|
|
|
|
$this->description = "Returns the highlighted fr.wikipedia.org article.";
|
2016-06-04 10:05:13 +03:00
|
|
|
$this->update = "2016-06-04";
|
2015-11-05 14:20:11 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-01-02 14:26:15 +04:00
|
|
|
public function collectData(array $param){
|
|
|
|
$html = '';
|
|
|
|
$host = 'http://fr.wikipedia.org';
|
|
|
|
// If you want HTTPS access instead, uncomment the following line:
|
|
|
|
//$host = 'https://fr.wikipedia.org';
|
|
|
|
$link = '/wiki/Wikip%C3%A9dia:Accueil_principal';
|
|
|
|
|
2016-06-26 00:17:42 +03:00
|
|
|
$html = $this->file_get_html($host.$link) or $this->returnError('Could not request Wikipedia FR.', 404);
|
2014-01-02 14:26:15 +04:00
|
|
|
|
2016-06-04 10:05:13 +03:00
|
|
|
$element = $html->find('div[id=mf-lumieresur]', 0);
|
2016-06-10 16:32:58 +03:00
|
|
|
# Use the "Lire la suite" link to dependably get the title of the article
|
|
|
|
# usually it's a child of a li.BA element (Bon article)
|
|
|
|
# occasionally it's a li.AdQ (Article de qualité)
|
|
|
|
$lirelasuite_link = $element->find('.BA > i > a, .AdQ > i > a', 0);
|
2014-01-02 14:26:15 +04:00
|
|
|
$item = new \Item();
|
2016-06-10 16:32:58 +03:00
|
|
|
$item->uri = $host.$lirelasuite_link->href;
|
|
|
|
$item->title = $lirelasuite_link->title;
|
2016-06-04 10:05:13 +03:00
|
|
|
$item->content = str_replace('href="/', 'href="'.$host.'/', $element->innertext);
|
2014-01-02 14:26:15 +04:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName(){
|
|
|
|
return 'Wikipedia FR "Lumière sur..."';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getURI(){
|
|
|
|
return 'https://fr.wikipedia.org/wiki/Wikip%C3%A9dia:Accueil_principal';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheDuration(){
|
2014-01-02 14:42:02 +04:00
|
|
|
return 3600*4; // 4 hours
|
2014-01-02 14:26:15 +04:00
|
|
|
}
|
|
|
|
}
|