LesJoiesDuCodeBridge.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. class LesJoiesDuCodeBridge extends BridgeAbstract{
  3. const MAINTAINER = "superbaillot.net";
  4. const NAME = "Les Joies Du Code";
  5. const URI = "http://lesjoiesducode.fr/";
  6. const CACHE_TIMEOUT = 7200; // 2h
  7. const DESCRIPTION = "LesJoiesDuCode";
  8. public function collectData(){
  9. $html = getSimpleHTMLDOM(self::URI)
  10. or returnServerError('Could not request LesJoiesDuCode.');
  11. foreach($html->find('div.blog-post') as $element) {
  12. $item = array();
  13. $temp = $element->find('h1 a', 0);
  14. $titre = html_entity_decode($temp->innertext);
  15. $url = $temp->href;
  16. $temp = $element->find('div.blog-post-content', 0);
  17. // retrieve .gif instead of static .jpg
  18. $images = $temp->find('p img');
  19. foreach($images as $image){
  20. $img_src = str_replace(".jpg",".gif",$image->src);
  21. $image->src = $img_src;
  22. }
  23. $content = $temp->innertext;
  24. $auteur = $temp->find('i', 0);
  25. $pos = strpos($auteur->innertext, "by");
  26. if($pos > 0)
  27. {
  28. $auteur = trim(str_replace("*/", "", substr($auteur->innertext, ($pos + 2))));
  29. $item['author'] = $auteur;
  30. }
  31. $item['content'] .= trim($content);
  32. $item['uri'] = $url;
  33. $item['title'] = trim($titre);
  34. $this->items[] = $item;
  35. }
  36. }
  37. }