Rss-Bridge/bridges/DuckDuckGoBridge.php
Pierre Mazière bba216073c [bridges] remove useless 'update' property from all bridges
That's the source code manager job to keep this information
consistent

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
2016-08-21 00:21:41 +02:00

38 lines
1 KiB
PHP

<?php
class DuckDuckGoBridge extends BridgeAbstract{
public function loadMetadatas() {
$this->maintainer = "Astalaseven";
$this->name = "DuckDuckGo";
$this->uri = "https://duckduckgo.com/";
$this->description = "Returns most recent results from DuckDuckGo.";
$this->parameters[] =
'[
{
"name" : "keyword",
"identifier" : "u"
}
]';
}
public function collectData(array $param){
$html = '';
$link = 'http://duckduckgo.com/html/?q='.$param[u].'+sort:date';
$html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request DuckDuckGo.');
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 getCacheDuration(){
return 21600; // 6 hours
}
}