mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-30 21:30:14 +02:00
fix(duckduckgo): order by date (#3689)
This commit is contained in:
@@ -8,7 +8,7 @@ class DuckDuckGoBridge extends BridgeAbstract
|
||||
const CACHE_TIMEOUT = 21600; // 6h
|
||||
const DESCRIPTION = 'Returns results from DuckDuckGo.';
|
||||
|
||||
const SORT_DATE = '+sort:date';
|
||||
const SORT_DATE = ' sort:date';
|
||||
const SORT_RELEVANCE = '';
|
||||
|
||||
const PARAMETERS = [ [
|
||||
@@ -31,13 +31,22 @@ class DuckDuckGoBridge extends BridgeAbstract
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
$html = getSimpleHTMLDOM(self::URI . 'html/?kd=-1&q=' . $this->getInput('u') . $this->getInput('sort'));
|
||||
$query = [
|
||||
'kd' => '-1',
|
||||
'q' => $this->getInput('u') . $this->getInput('sort'),
|
||||
];
|
||||
$url = 'https://duckduckgo.com/html/?' . http_build_query($query);
|
||||
$html = getSimpleHTMLDOM($url);
|
||||
|
||||
foreach ($html->find('div.result') as $element) {
|
||||
$item = [];
|
||||
$item['uri'] = $element->find('a.result__a', 0)->href;
|
||||
$item['title'] = $element->find('h2.result__title', 0)->plaintext;
|
||||
$item['content'] = $element->find('a.result__snippet', 0)->plaintext;
|
||||
|
||||
$snippet = $element->find('a.result__snippet', 0);
|
||||
if ($snippet) {
|
||||
$item['content'] = $snippet->plaintext;
|
||||
}
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user