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/";
|
2016-09-25 17:04:28 +02:00
|
|
|
const CACHE_TIMEOUT = 21600; // 6h
|
2016-08-30 11:23:55 +02:00
|
|
|
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-08-30 11:23:55 +02:00
|
|
|
$html = $this->getSimpleHTMLDOM(self::URI.'html/?q='.$this->getInput('u').'+sort:date')
|
2016-08-28 14:05:39 +02:00
|
|
|
or $this->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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|