ScmbBridge.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * RssBridgeSeCoucherMoinsBete
  4. * Returns the newest anecdotes
  5. * 2014-05-25
  6. *
  7. * @name Se Coucher Moins Bête Bridge
  8. * @homepage http://secouchermoinsbete.fr/
  9. * @description Returns the newest anecdotes.
  10. * @maintainer Astalaseven
  11. */
  12. class ScmbBridge extends BridgeAbstract{
  13. public function collectData(array $param){
  14. $html = '';
  15. $html = file_get_html('http://secouchermoinsbete.fr/') or $this->returnError('Could not request Se Coucher Moins Bete.', 404);
  16. foreach($html->find('article') as $article) {
  17. $item = new \Item();
  18. $item->uri = 'http://secouchermoinsbete.fr'.$article->find('p.summary a',0)->href;
  19. $item->title = $article->find('header h1 a',0)->innertext;
  20. $article->find('span.read-more',0)->outertext=''; // remove text "En savoir plus" from anecdote content
  21. $content = $article->find('p.summary a',0)->innertext;
  22. $content =substr($content,0,strlen($content)-17); // remove superfluous spaces at the end
  23. // get publication date
  24. $str_date = $article->find('time',0)->datetime;
  25. list($date, $time) = explode(' ', $str_date);
  26. list($y, $m, $d) = explode('-', $date);
  27. list($h, $i) = explode(':', $time);
  28. $timestamp = mktime($h,$i,0,$m,$d,$y);
  29. $item->timestamp = $timestamp;
  30. $item->content = $content;
  31. $this->items[] = $item;
  32. }
  33. }
  34. public function getName(){
  35. return 'Se Coucher Moins Bête Bridge';
  36. }
  37. public function getURI(){
  38. return 'http://secouchermoinsbete.fr/';
  39. }
  40. public function getCacheDuration(){
  41. return 21600; // 6 hours
  42. }
  43. }