1
0

BastaBridge.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * RssBridgeBastabag
  4. * Returns the newest articles
  5. * 2014-05-25
  6. *
  7. * @name Bastamag Bridge
  8. * @homepage http://www.bastamag.net/
  9. * @description Returns the newest articles.
  10. * @maintainer qwertygc
  11. */
  12. class BastaBridge extends BridgeAbstract{
  13. public function collectData(array $param){
  14. function BastaExtractContent($url) {
  15. $html2 = file_get_html($url);
  16. $text = $html2->find('div.texte', 0)->innertext;
  17. return $text;
  18. }
  19. $html = file_get_html('http://www.bastamag.net/spip.php?page=backend') or $this->returnError('Could not request Bastamag.', 404);
  20. $limit = 0;
  21. foreach($html->find('item') as $element) {
  22. if($limit < 10) {
  23. $item = new \Item();
  24. $item->title = $element->find('title', 0)->innertext;
  25. $item->uri = $element->find('guid', 0)->plaintext;
  26. $item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
  27. $item->content = BastaExtractContent($item->uri);
  28. $this->items[] = $item;
  29. $limit++;
  30. }
  31. }
  32. }
  33. public function getName(){
  34. return 'Bastamag Bridge';
  35. }
  36. public function getURI(){
  37. return 'http://bastamag.net/';
  38. }
  39. public function getCacheDuration(){
  40. return 3600*2; // 2 hours
  41. // return 0; // 2 hours
  42. }
  43. }