TheCodingLoveBridge.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. $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. }