TheCodingLoveBridge.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 CACHE_TIMEOUT = 7200; // 2h
  7. const DESCRIPTION = "The Coding Love";
  8. public function collectData(){
  9. $html = getSimpleHTMLDOM(self::URI)
  10. or returnServerError('Could not request The Coding Love.');
  11. foreach($html->find('div.post') as $element) {
  12. $item = array();
  13. $temp = $element->find('h3 a', 0);
  14. $titre = $temp->innertext;
  15. $url = $temp->href;
  16. $temp = $element->find('div.bodytype', 0);
  17. // retrieve .gif instead of static .jpg
  18. $images = $temp->find('p.e 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. }