1
0
Fork 0
forked from blallo/rss-bridge
rss-bridge/bridges/DuckDuckGoBridge.php
Pierre Mazière f1fb95b257 [core] extract BridgeAbstract methods to make them functions
- returnError, returnServerError, returnClientError ,debugMessage are
  moved to lib/error.php

- getContents, getSimpleHTMLDOM, getSimpleHTMLDOMCached are moved to
  lib/contents.php

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
2016-09-25 23:22:33 +02:00

31 lines
994 B
PHP

<?php
class DuckDuckGoBridge extends BridgeAbstract{
const MAINTAINER = "Astalaseven";
const NAME = "DuckDuckGo";
const URI = "https://duckduckgo.com/";
const DESCRIPTION = "Returns most recent results from DuckDuckGo.";
const PARAMETERS = array( array(
'u'=>array(
'name'=>'keyword',
'required'=>true)
));
public function collectData(){
$html = getSimpleHTMLDOM(self::URI.'html/?q='.$this->getInput('u').'+sort:date')
or 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
}
}