ScmbBridge.php 1.5 KB

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