1
0

DuckDuckGoBridge.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * RssBridgeDuckDuckGo
  4. * Search DuckDuckGo for most recent pages regarding a specific topic.
  5. * Returns the most recent links in results, sorting by date (most recent first).
  6. * 2014-05-25
  7. *
  8. * @name DuckDuckGo
  9. * @homepage https://duckduckgo.com/
  10. * @description Returns most recent results from DuckDuckGo.
  11. * @maintainer Astalaseven
  12. * @use1(u="keyword")
  13. */
  14. class DuckDuckGoBridge extends BridgeAbstract{
  15. public function collectData(array $param){
  16. $html = '';
  17. $link = 'http://duckduckgo.com/html/?q='.$param[u].'+sort:date';
  18. $html = file_get_html($link) or $this->returnError('Could not request DuckDuckGo.', 404);
  19. foreach($html->find('div.results_links') as $element) {
  20. $item = new \Item();
  21. $item->uri = $element->find('a', 0)->href;
  22. $item->title = $element->find('a', 1)->innertext;
  23. $item->content = $element->find('div.snippet', 0)->plaintext;
  24. $this->items[] = $item;
  25. }
  26. }
  27. public function getName(){
  28. return 'DuckDuckGo';
  29. }
  30. public function getURI(){
  31. return 'https://duckduckgo.com';
  32. }
  33. public function getCacheDuration(){
  34. return 21600; // 6 hours
  35. }
  36. }