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