TheCodingLoveBridge.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. class TheCodingLoveBridge extends BridgeAbstract{
  3. public function loadMetadatas() {
  4. $this->maintainer = "superbaillot.net";
  5. $this->name = "The Coding Love";
  6. $this->uri = "http://thecodinglove.com/";
  7. $this->description = "The Coding Love";
  8. }
  9. public function collectData(array $param){
  10. $html = $this->getSimpleHTMLDOM('http://thecodinglove.com/') or $this->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. public function getCacheDuration(){
  38. return 7200; // 2h hours
  39. }
  40. }