1
0

ScoopItBridge.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * RssBridgeScoopIt
  4. * Search DScoopIt for most recent pages regarding a specific topic.
  5. * Returns the most recent links in results, sorting by date (most recent first).
  6. * 2014-06-13
  7. *
  8. * @name ScoopIt
  9. * @homepage http://www.scoop.it
  10. * @description Returns most recent results from ScoopIt.
  11. * @maintainer Pitchoule
  12. * @use1(u="keyword")
  13. */
  14. class ScoopItBridge extends BridgeAbstract{
  15. public function collectData(array $param){
  16. $html = '';
  17. if ($param['u'] != '') {
  18. $this->request = $param['u'];
  19. $link = 'http://scoop.it/search?q=' .urlencode($this->request);
  20. $html = file_get_html($link) or $this->returnError('Could not request ScoopIt. for : ' . $link , 404);
  21. foreach($html->find('div.post-view') as $element) {
  22. $item = new Item();
  23. $item->uri = $element->find('a', 0)->href;
  24. $item->title = preg_replace('~[[:cntrl:]]~', '', $element->find('div.tCustomization_post_title',0)->plaintext);
  25. $item->content = preg_replace('~[[:cntrl:]]~', '', $element->find('div.tCustomization_post_description', 0)->plaintext);
  26. $this->items[] = $item;
  27. }
  28. } else {
  29. $this->returnError('You must specify a keyword', 404);
  30. }
  31. }
  32. public function getName(){
  33. return 'ScooptIt';
  34. }
  35. public function getURI(){
  36. return 'http://Scoop.it';
  37. }
  38. public function getCacheDuration(){
  39. return 21600; // 6 hours
  40. }
  41. }