2013-12-16 15:29:33 +01:00
|
|
|
<?php
|
|
|
|
class DuckDuckGoBridge extends BridgeAbstract{
|
|
|
|
|
2015-11-05 16:50:18 +01:00
|
|
|
public function loadMetadatas() {
|
|
|
|
|
|
|
|
$this->maintainer = "Astalaseven";
|
|
|
|
$this->name = "DuckDuckGo";
|
|
|
|
$this->uri = "https://duckduckgo.com/";
|
|
|
|
$this->description = "Returns most recent results from DuckDuckGo.";
|
|
|
|
|
2016-08-22 01:25:56 +02:00
|
|
|
$this->parameters[] = array(
|
|
|
|
'u'=>array(
|
|
|
|
'name'=>'keyword',
|
|
|
|
'required'=>true)
|
|
|
|
);
|
2015-11-05 16:50:18 +01:00
|
|
|
}
|
|
|
|
|
2013-12-16 15:29:33 +01:00
|
|
|
public function collectData(array $param){
|
|
|
|
$html = '';
|
2016-08-21 16:59:28 +02:00
|
|
|
$link = 'http://duckduckgo.com/html/?q='.$param['u'].'+sort:date';
|
2013-12-16 15:29:33 +01:00
|
|
|
|
2016-07-08 19:06:35 +02:00
|
|
|
$html = $this->getSimpleHTMLDOM($link) 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheDuration(){
|
|
|
|
return 21600; // 6 hours
|
|
|
|
}
|
|
|
|
}
|