ScmbBridge.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. class ScmbBridge extends BridgeAbstract{
  3. const MAINTAINER = "Astalaseven";
  4. const NAME = "Se Coucher Moins Bête Bridge";
  5. const URI = "http://secouchermoinsbete.fr/";
  6. const DESCRIPTION = "Returns the newest anecdotes.";
  7. public function collectData(){
  8. $html = '';
  9. $html = getSimpleHTMLDOM(self::URI)
  10. or returnServerError('Could not request Se Coucher Moins Bete.');
  11. foreach($html->find('article') as $article) {
  12. $item = array();
  13. $item['uri'] = self::URI.$article->find('p.summary a',0)->href;
  14. $item['title'] = $article->find('header h1 a',0)->innertext;
  15. $article->find('span.read-more',0)->outertext=''; // remove text "En savoir plus" from anecdote content
  16. $content = $article->find('p.summary a',0)->innertext;
  17. $content =substr($content,0,strlen($content)-17); // remove superfluous spaces at the end
  18. // get publication date
  19. $str_date = $article->find('time',0)->datetime;
  20. list($date, $time) = explode(' ', $str_date);
  21. list($y, $m, $d) = explode('-', $date);
  22. list($h, $i) = explode(':', $time);
  23. $timestamp = mktime($h,$i,0,$m,$d,$y);
  24. $item['timestamp'] = $timestamp;
  25. $item['content'] = $content;
  26. $this->items[] = $item;
  27. }
  28. }
  29. public function getCacheDuration(){
  30. return 21600; // 6 hours
  31. }
  32. }