OpenClassroomsBridge.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * RssBridgeOpenClassrooms
  4. * Retrieve lastest tutorials from OpenClassrooms.
  5. * Returns the most recent tutorials, sorting by date (most recent first).
  6. *
  7. * @name OpenClassrooms Bridge
  8. * @description Returns latest tutorials from OpenClassrooms.
  9. * @maintainer sebsauvage
  10. * @use1(u="informatique or sciences")
  11. */
  12. class OpenClassroomsBridge extends BridgeAbstract{
  13. public function collectData(array $param){
  14. if ($param['u']!='informatique' && $param['u']!='sciences')
  15. {
  16. $this->returnError('Error: You must chose "informatique" or "science".', 404);
  17. }
  18. $html = '';
  19. $link = 'http://fr.openclassrooms.com/'.$param['u'].'/cours?title=&sort=updatedAt+desc';
  20. $html = file_get_html($link) or $this->returnError('Could not request OpenClassrooms.', 404);
  21. foreach($html->find('li.col6') as $element) {
  22. $item = new \Item();
  23. $item->uri = 'http://fr.openclassrooms.com'.$element->find('a', 0)->href;
  24. $item->title = $element->find('div.courses-content strong', 0)->innertext;
  25. $item->content = $element->find('span.course-tags', 0)->innertext;
  26. $this->items[] = $item;
  27. }
  28. }
  29. public function getName(){
  30. return 'OpenClassrooms';
  31. }
  32. public function getURI(){
  33. return 'http://fr.openclassrooms.com';
  34. }
  35. public function getCacheDuration(){
  36. return 21600; // 6 hours
  37. }
  38. }