ScoopItBridge.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. class ScoopItBridge extends BridgeAbstract {
  3. const MAINTAINER = 'Pitchoule';
  4. const NAME = 'ScoopIt';
  5. const URI = 'http://www.scoop.it/';
  6. const CACHE_TIMEOUT = 21600; // 6h
  7. const DESCRIPTION = 'Returns most recent results from ScoopIt.';
  8. const PARAMETERS = array( array(
  9. 'u' => array(
  10. 'name' => 'keyword',
  11. 'required' => true
  12. )
  13. ));
  14. public function collectData(){
  15. $this->request = $this->getInput('u');
  16. $link = self::URI . 'search?q=' . urlencode($this->getInput('u'));
  17. $html = getSimpleHTMLDOM($link)
  18. or returnServerError('Could not request ScoopIt. for : ' . $link);
  19. foreach($html->find('div.post-view') as $element) {
  20. $item = array();
  21. $item['uri'] = $element->find('a', 0)->href;
  22. $item['title'] = preg_replace(
  23. '~[[:cntrl:]]~',
  24. '',
  25. $element->find('div.tCustomization_post_title', 0)->plaintext
  26. );
  27. $item['content'] = preg_replace(
  28. '~[[:cntrl:]]~',
  29. '',
  30. $element->find('div.tCustomization_post_description', 0)->plaintext
  31. );
  32. $this->items[] = $item;
  33. }
  34. }
  35. }