summaryrefslogtreecommitdiff
path: root/searx/engines/duckduckgo.py
diff options
context:
space:
mode:
authorNoémi Ványi <sitbackandwait@gmail.com>2019-01-06 15:27:46 +0100
committerNoémi Ványi <sitbackandwait@gmail.com>2019-01-07 21:19:00 +0100
commitb63d645a52d663036b97e31a59818d79faa4da81 (patch)
tree6ba72217200a0f52f82ba8244afbee19c24d098c /searx/engines/duckduckgo.py
parent491792c1a58f71083f6af663bb6d93e40fa44c9f (diff)
downloadsearxng-b63d645a52d663036b97e31a59818d79faa4da81.tar.gz
searxng-b63d645a52d663036b97e31a59818d79faa4da81.zip
Revert "remove 'all' option from search languages"
This reverts commit 4d1770398a6af8902e75c0bd885781584d39e796.
Diffstat (limited to 'searx/engines/duckduckgo.py')
-rw-r--r--searx/engines/duckduckgo.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/searx/engines/duckduckgo.py b/searx/engines/duckduckgo.py
index 2c5dc50d8..fb8f523ac 100644
--- a/searx/engines/duckduckgo.py
+++ b/searx/engines/duckduckgo.py
@@ -54,6 +54,9 @@ content_xpath = './/a[@class="result__snippet"]'
# match query's language to a region code that duckduckgo will accept
def get_region_code(lang, lang_list=[]):
+ if lang == 'all':
+ return None
+
lang_code = match_language(lang, lang_list, language_aliases, 'wt-WT')
lang_parts = lang_code.split('-')
@@ -61,7 +64,6 @@ def get_region_code(lang, lang_list=[]):
return lang_parts[1].lower() + '-' + lang_parts[0].lower()
-# do search-request
def request(query, params):
if params['time_range'] and params['time_range'] not in time_range_dict:
return params
@@ -69,8 +71,12 @@ def request(query, params):
offset = (params['pageno'] - 1) * 30
region_code = get_region_code(params['language'], supported_languages)
- params['url'] = url.format(
- query=urlencode({'q': query, 'kl': region_code}), offset=offset, dc_param=offset)
+ if region_code:
+ params['url'] = url.format(
+ query=urlencode({'q': query, 'kl': region_code}), offset=offset, dc_param=offset)
+ else:
+ params['url'] = url.format(
+ query=urlencode({'q': query}), offset=offset, dc_param=offset)
if params['time_range'] in time_range_dict:
params['url'] += time_range_url.format(range=time_range_dict[params['time_range']])