commit: f13b9fa36ae51861b8c5a1e110895af0f8c5f555
parent 2e5839503f7a147e6759e124a3694d1e6b6631fd
Author: Noemi Vanyi <sitbackandwait@gmail.com>
Date: Mon, 18 Jul 2016 16:15:37 +0200
add time range search for duckduckgo
Diffstat:
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git 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