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.";
|
|
|
|
$this->update = "2014-05-25";
|
|
|
|
|
|
|
|
$this->parameters[] =
|
|
|
|
'[
|
|
|
|
{
|
|
|
|
"name" : "keyword",
|
|
|
|
"identifier" : "u"
|
|
|
|
}
|
|
|
|
]';
|
|
|
|
}
|
|
|
|
|
2013-12-16 15:29:33 +01:00
|
|
|
public function collectData(array $param){
|
|
|
|
$html = '';
|
2014-02-08 18:12:49 +01:00
|
|
|
$link = 'http://duckduckgo.com/html/?q='.$param[u].'+sort:date';
|
2013-12-16 15:29:33 +01:00
|
|
|
|
2016-06-25 23:17:42 +02:00
|
|
|
$html = $this->file_get_html($link) or $this->returnError('Could not request DuckDuckGo.', 404);
|
2013-12-16 15:29:33 +01:00
|
|
|
|
|
|
|
foreach($html->find('div.results_links') as $element) {
|
|
|
|
$item = new \Item();
|
|
|
|
$item->uri = $element->find('a', 0)->href;
|
|
|
|
$item->title = $element->find('a', 1)->innertext;
|
|
|
|
$item->content = $element->find('div.snippet', 0)->plaintext;
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName(){
|
|
|
|
return 'DuckDuckGo';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getURI(){
|
|
|
|
return 'https://duckduckgo.com';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheDuration(){
|
|
|
|
return 21600; // 6 hours
|
|
|
|
}
|
|
|
|
}
|