ScmbBridge.php 1.5 KB

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