1
0

GizmodoFRBridge.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * RssBridgeGizmodoFR
  4. * Returns the 15 newest posts from http://www.gizmodo.fr (full text)
  5. * 2014-07-14
  6. *
  7. * @name GizmodoFR
  8. * @homepage http://www.gizmodo.fr/
  9. * @description Returns the 15 newest posts from GizmodoFR (full text).
  10. * @maintainer polopollo
  11. */
  12. class GizmodoFRBridge extends BridgeAbstract{
  13. public function collectData(array $param){
  14. function GizmodoFRExtractContent($url) {
  15. $articleHTMLContent = file_get_html($url);
  16. $text = $articleHTMLContent->find('div.entry-thumbnail', 0)->innertext;
  17. $text = $text.$articleHTMLContent->find('div.entry-excerpt', 0)->innertext;
  18. $text = $text.$articleHTMLContent->find('div.entry-content', 0)->innertext;
  19. foreach($articleHTMLContent->find('pagespeed_iframe') as $element) {
  20. $text = $text.'<p>link to a iframe (could be a video): <a href="'.$element->src.'">'.$element->src.'</a></p><br>';
  21. }
  22. $text = strip_tags($text, '<p><b><a><blockquote><img><em>');
  23. return $text;
  24. }
  25. $rssFeed = file_get_html('http://www.gizmodo.fr/feed') or $this->returnError('Could not request http://www.gizmodo.fr/feed', 404);
  26. $limit = 0;
  27. foreach($rssFeed->find('item') as $element) {
  28. if($limit < 15) {
  29. $item = new \Item();
  30. $item->title = $element->find('title', 0)->innertext;
  31. $item->uri = $element->find('guid', 0)->plaintext;
  32. $item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
  33. $item->content = GizmodoFRExtractContent($item->uri);
  34. $this->items[] = $item;
  35. $limit++;
  36. }
  37. }
  38. }
  39. public function getName(){
  40. return 'GizmodoFR';
  41. }
  42. public function getURI(){
  43. return 'http://www.gizmodo.fr/';
  44. }
  45. public function getCacheDuration(){
  46. return 1800; // 30min
  47. }
  48. }