rss-bridge/bridges/DuckDuckGoBridge.php

37 lines
1.1 KiB
PHP
Raw Normal View History

2013-12-16 18:29:33 +04:00
<?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[] = array(
'u'=>array(
'name'=>'keyword',
'required'=>true)
);
}
2013-12-16 18:29:33 +04:00
public function collectData(array $param){
$html = '';
$link = 'http://duckduckgo.com/html/?q='.$param['u'].'+sort:date';
2013-12-16 18:29:33 +04:00
$html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request DuckDuckGo.');
2013-12-16 18:29:33 +04:00
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;
2013-12-16 18:29:33 +04:00
$this->items[] = $item;
}
}
public function getCacheDuration(){
return 21600; // 6 hours
}
}