Rss-Bridge/bridges/OpenClassroomsBridge.php

48 lines
1.6 KiB
PHP
Raw Normal View History

2013-12-16 09:07:48 +01:00
<?php
/**
* RssBridgeOpenClassrooms
* Retrieve lastest tutorials from OpenClassrooms.
* Returns the most recent tutorials, sorting by date (most recent first).
*
* @name OpenClassrooms Bridge
2015-10-30 18:27:49 +01:00
* @homepage https://openclassrooms.com/
2013-12-16 09:07:48 +01:00
* @description Returns latest tutorials from OpenClassrooms.
2014-05-21 19:44:14 +02:00
* @maintainer sebsauvage
2015-10-30 18:27:49 +01:00
* @update 2015-10-30
* @use1(list|u="Arts & Culture=>arts;Code=>code;Design=>design;Entreprise=>business;Numérique=>digital;Sciences=>sciences;Sciences humaines=>humanities;Systèmes d'information=>it;Autres=>others")
2013-12-16 09:07:48 +01:00
*/
class OpenClassroomsBridge extends BridgeAbstract{
public function collectData(array $param){
2015-10-30 18:27:49 +01:00
if (empty($param['u']))
{
2015-10-30 18:27:49 +01:00
$this->returnError('Error: You must chose a category.', 404);
}
2013-12-16 09:07:48 +01:00
$html = '';
2015-10-30 18:27:49 +01:00
$link = 'https://openclassrooms.com/courses?categories='.$param['u'].'&title=&sort=updatedAt+desc';
2013-12-16 09:07:48 +01:00
$html = file_get_html($link) or $this->returnError('Could not request OpenClassrooms.', 404);
2015-10-30 18:27:49 +01:00
foreach($html->find('.courseListItem') as $element) {
2013-12-16 09:07:48 +01:00
$item = new \Item();
2015-10-30 18:27:49 +01:00
$item->uri = 'https://openclassrooms.com'.$element->find('a', 0)->href;
$item->title = $element->find('h3', 0)->plaintext;
$item->content = $element->find('slidingItem__descriptionContent', 0)->plaintext;
2013-12-16 09:07:48 +01:00
$this->items[] = $item;
}
}
public function getName(){
return 'OpenClassrooms';
}
public function getURI(){
2015-10-30 18:27:49 +01:00
return 'https://openclassrooms.com/';
2013-12-16 09:07:48 +01:00
}
public function getCacheDuration(){
return 21600; // 6 hours
}
}