mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-26 19:36:52 +03:00
de1b39c8e5
if a bridge needs to modify some of the data that were initialized there, ::__construct() should be used instead. Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
34 lines
1.1 KiB
PHP
34 lines
1.1 KiB
PHP
<?php
|
|
class DuckDuckGoBridge extends BridgeAbstract{
|
|
|
|
public $maintainer = "Astalaseven";
|
|
public $name = "DuckDuckGo";
|
|
public $uri = "https://duckduckgo.com/";
|
|
public $description = "Returns most recent results from DuckDuckGo.";
|
|
|
|
public $parameters = array( array(
|
|
'u'=>array(
|
|
'name'=>'keyword',
|
|
'required'=>true)
|
|
));
|
|
|
|
public function collectData(){
|
|
$param=$this->parameters[$this->queriedContext];
|
|
$html = '';
|
|
$link = 'http://duckduckgo.com/html/?q='.$param['u']['value'].'+sort:date';
|
|
|
|
$html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request DuckDuckGo.');
|
|
|
|
foreach($html->find('div.results_links') as $element) {
|
|
$item = array();
|
|
$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
|
|
}
|
|
}
|