From f13b9fa36ae51861b8c5a1e110895af0f8c5f555 Mon Sep 17 00:00:00 2001 From: Noemi Vanyi Date: Mon, 18 Jul 2016 16:15:37 +0200 Subject: [PATCH] add time range search for duckduckgo --- searx/engines/duckduckgo.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/searx/engines/duckduckgo.py b/searx/engines/duckduckgo.py index d29e4416a..aa7a98754 100644 --- a/searx/engines/duckduckgo.py +++ b/searx/engines/duckduckgo.py @@ -22,9 +22,15 @@ from searx.languages import language_codes categories = ['general'] paging = True language_support = True +time_range_support = True # search-url url = 'https://duckduckgo.com/html?{query}&s={offset}' +time_range_url = '&df={range}' + +time_range_dict = {'day': 'd', + 'week': 'w', + 'month': 'm'} # specific xpath variables result_xpath = '//div[@class="result results_links results_links_deep web-result "]' # noqa @@ -61,6 +67,9 @@ def request(query, params): params['url'] = url.format( query=urlencode({'q': query}), offset=offset) + if params['time_range']: + params['url'] += time_range_url.format(range=time_range_dict[params['time_range']]) + return params