ScmbBridge.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 CACHE_TIMEOUT = 21600; // 6h
  7. const DESCRIPTION = "Returns the newest anecdotes.";
  8. public function collectData(){
  9. $html = '';
  10. $html = getSimpleHTMLDOM(self::URI)
  11. or returnServerError('Could not request Se Coucher Moins Bete.');
  12. foreach($html->find('article') as $article) {
  13. $item = array();
  14. $item['uri'] = self::URI.$article->find('p.summary a',0)->href;
  15. $item['title'] = $article->find('header h1 a',0)->innertext;
  16. $article->find('span.read-more',0)->outertext=''; // remove text "En savoir plus" from anecdote content
  17. $content = $article->find('p.summary a',0)->innertext;
  18. $content =substr($content,0,strlen($content)-17); // remove superfluous spaces at the end
  19. // get publication date
  20. $str_date = $article->find('time',0)->datetime;
  21. list($date, $time) = explode(' ', $str_date);
  22. list($y, $m, $d) = explode('-', $date);
  23. list($h, $i) = explode(':', $time);
  24. $timestamp = mktime($h,$i,0,$m,$d,$y);
  25. $item['timestamp'] = $timestamp;
  26. $item['content'] = $content;
  27. $this->items[] = $item;
  28. }
  29. }
  30. }