2014-01-02 11:26:15 +01:00
|
|
|
<?php
|
|
|
|
class WikipediaFRBridge extends BridgeAbstract{
|
|
|
|
|
2015-11-05 12:20:11 +01: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 09:05:13 +02:00
|
|
|
$this->update = "2016-06-04";
|
2015-11-05 12:20:11 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-01-02 11:26:15 +01: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-25 23:17:42 +02:00
|
|
|
$html = $this->file_get_html($host.$link) or $this->returnError('Could not request Wikipedia FR.', 404);
|
2014-01-02 11:26:15 +01:00
|
|
|
|
2016-06-04 09:05:13 +02:00
|
|
|
$element = $html->find('div[id=mf-lumieresur]', 0);
|
2016-06-10 15:32:58 +02: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 11:26:15 +01:00
|
|
|
$item = new \Item();
|
2016-06-10 15:32:58 +02:00
|
|
|
$item->uri = $host.$lirelasuite_link->href;
|
|
|
|
$item->title = $lirelasuite_link->title;
|
2016-06-04 09:05:13 +02:00
|
|
|
$item->content = str_replace('href="/', 'href="'.$host.'/', $element->innertext);
|
2014-01-02 11:26:15 +01: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 11:42:02 +01:00
|
|
|
return 3600*4; // 4 hours
|
2014-01-02 11:26:15 +01:00
|
|
|
}
|
|
|
|
}
|