summaryrefslogtreecommitdiff
path: root/searx/engines/duckduckgo.py
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2016-07-26 00:06:16 +0200
committerGitHub <noreply@github.com>2016-07-26 00:06:16 +0200
commit7d9c898170df497036b8a7a70a1a5c86c3859670 (patch)
treeca1722a5d0d1bc8493e50bd334a07ea50e744e63 /searx/engines/duckduckgo.py
parent54d987636e4b03d19a99ad9d143bf63b119af208 (diff)
parent90e74fbb288b2f1df0516d877d3bd239c7800412 (diff)
Merge pull request #634 from kvch/advanced-search
support time range search
Diffstat (limited to 'searx/engines/duckduckgo.py')
-rw-r--r--searx/engines/duckduckgo.py9
1 files changed, 9 insertions, 0 deletions
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