diff --git a/bridges/BlaguesDeMerdeBridge.php b/bridges/BlaguesDeMerdeBridge.php index 3ae59a1..78deda0 100644 --- a/bridges/BlaguesDeMerdeBridge.php +++ b/bridges/BlaguesDeMerdeBridge.php @@ -1,31 +1,43 @@ find('article.joke_contener') as $element) { - $item = array(); - $temp = $element->find('a'); + foreach($html->find('div.blague') as $element) { + + $item = array(); + + $item['uri'] = static::URI . '#' . $element->id; + $item['author'] = $element->find('div[class="blague-footer"] p strong', 0)->plaintext; + + // Let the title be everything up to the first
+ $item['title'] = trim(explode("\n", $element->find('div.text', 0)->plaintext)[0]); + + $item['content'] = strip_tags($element->find('div.text', 0)); + + // timestamp is part of: + //

Par {author} le {date} dans {category}

+ preg_match( + '/.+le(.+)dans.*/', + $element->find('div[class="blague-footer"]', 0)->plaintext, + $matches + ); + + $item['timestamp'] = strtotime($matches[1]); + + $this->items[] = $item; - if(isset($temp[2])) { - $item['content'] = trim($element->find('div.joke_text_contener', 0)->innertext); - $uri = $temp[2]->href; - $item['uri'] = $uri; - $item['title'] = substr($uri, (strrpos($uri, '/') + 1)); - $date = $element->find('li.bdm_date', 0)->innertext; - $time = mktime(0, 0, 0, substr($date, 3, 2), substr($date, 0, 2), substr($date, 6, 4)); - $item['timestamp'] = $time; - $item['author'] = $element->find('li.bdm_pseudo', 0)->innertext; - $this->items[] = $item; - } } + } + }