2013-12-16 18:29:33 +04:00
|
|
|
<?php
|
|
|
|
class DuckDuckGoBridge extends BridgeAbstract{
|
|
|
|
|
2016-08-30 12:23:55 +03:00
|
|
|
const MAINTAINER = "Astalaseven";
|
|
|
|
const NAME = "DuckDuckGo";
|
|
|
|
const URI = "https://duckduckgo.com/";
|
|
|
|
const DESCRIPTION = "Returns most recent results from DuckDuckGo.";
|
2015-11-05 18:50:18 +03:00
|
|
|
|
2016-08-30 12:23:55 +03:00
|
|
|
const PARAMETERS = array( array(
|
2016-08-27 22:03:26 +03:00
|
|
|
'u'=>array(
|
2016-08-22 02:25:56 +03:00
|
|
|
'name'=>'keyword',
|
|
|
|
'required'=>true)
|
2016-08-27 22:03:26 +03:00
|
|
|
));
|
2015-11-05 18:50:18 +03:00
|
|
|
|
2016-08-25 02:24:53 +03:00
|
|
|
public function collectData(){
|
2016-08-30 12:23:55 +03:00
|
|
|
$html = $this->getSimpleHTMLDOM(self::URI.'html/?q='.$this->getInput('u').'+sort:date')
|
2016-08-28 15:05:39 +03:00
|
|
|
or $this->returnServerError('Could not request DuckDuckGo.');
|
2013-12-16 18:29:33 +04:00
|
|
|
|
|
|
|
foreach($html->find('div.results_links') as $element) {
|
2016-08-22 19:55:59 +03:00
|
|
|
$item = array();
|
|
|
|
$item['uri'] = $element->find('a', 0)->href;
|
|
|
|
$item['title'] = $element->find('a', 1)->innertext;
|
|
|
|
$item['content'] = $element->find('div.snippet', 0)->plaintext;
|
2013-12-16 18:29:33 +04:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheDuration(){
|
|
|
|
return 21600; // 6 hours
|
|
|
|
}
|
|
|
|
}
|