rss-bridge/bridges/DuckDuckGoBridge.php

43 lines
1.2 KiB
PHP
Raw Normal View History

2013-12-16 15:29:33 +01:00
<?php
/**
* RssBridgeDuckDuckGo
* Search DuckDuckGo for most recent pages regarding a specific topic.
* Returns the most recent links in results, sorting by date (most recent first).
2014-05-25 23:27:14 +02:00
* 2014-05-25
2013-12-16 15:29:33 +01:00
*
* @name DuckDuckGo
2014-05-25 23:27:14 +02:00
* @homepage https://duckduckgo.com/
2013-12-16 15:29:33 +01:00
* @description Returns most recent results from DuckDuckGo.
2014-05-21 19:44:14 +02:00
* @maintainer Astalaseven
2013-12-16 15:29:33 +01:00
* @use1(u="keyword")
*/
class DuckDuckGoBridge extends BridgeAbstract{
public function collectData(array $param){
$html = '';
$link = 'http://duckduckgo.com/html/?q='.$param[u].'+sort:date';
2013-12-16 15:29:33 +01:00
$html = file_get_html($link) or $this->returnError('Could not request DuckDuckGo.', 404);
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
}
}