LesJoiesDuCodeBridge.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 DESCRIPTION = "LesJoiesDuCode";
  7. public function collectData(){
  8. $html = $this->getSimpleHTMLDOM(self::URI)
  9. or $this->returnServerError('Could not request LesJoiesDuCode.');
  10. foreach($html->find('div.blog-post') as $element) {
  11. $item = array();
  12. $temp = $element->find('h1 a', 0);
  13. $titre = html_entity_decode($temp->innertext);
  14. $url = $temp->href;
  15. $temp = $element->find('div.blog-post-content', 0);
  16. // retrieve .gif instead of static .jpg
  17. $images = $temp->find('p img');
  18. foreach($images as $image){
  19. $img_src = str_replace(".jpg",".gif",$image->src);
  20. $image->src = $img_src;
  21. }
  22. $content = $temp->innertext;
  23. $auteur = $temp->find('i', 0);
  24. $pos = strpos($auteur->innertext, "by");
  25. if($pos > 0)
  26. {
  27. $auteur = trim(str_replace("*/", "", substr($auteur->innertext, ($pos + 2))));
  28. $item['author'] = $auteur;
  29. }
  30. $item['content'] .= trim($content);
  31. $item['uri'] = $url;
  32. $item['title'] = trim($titre);
  33. $this->items[] = $item;
  34. }
  35. }
  36. public function getCacheDuration(){
  37. return 7200; // 2h hours
  38. }
  39. }