TheCodingLoveBridge.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. class TheCodingLoveBridge extends BridgeAbstract{
  3. const MAINTAINER = "superbaillot.net";
  4. const NAME = "The Coding Love";
  5. const URI = "http://thecodinglove.com/";
  6. const DESCRIPTION = "The Coding Love";
  7. public function collectData(){
  8. $html = getSimpleHTMLDOM(self::URI)
  9. or returnServerError('Could not request The Coding Love.');
  10. foreach($html->find('div.post') as $element) {
  11. $item = array();
  12. $temp = $element->find('h3 a', 0);
  13. $titre = $temp->innertext;
  14. $url = $temp->href;
  15. $temp = $element->find('div.bodytype', 0);
  16. // retrieve .gif instead of static .jpg
  17. $images = $temp->find('p.e 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. }