From 64b75e6d829d9fc8b742c94499b5219c12a053d7 Mon Sep 17 00:00:00 2001 From: dalf Date: Sun, 7 Sep 2014 22:52:13 +0200 Subject: [PATCH] [enh] duckduckgo engine: add language support --- searx/engines/duckduckgo.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/searx/engines/duckduckgo.py b/searx/engines/duckduckgo.py index cd7d93c51..296dd9b2d 100644 --- a/searx/engines/duckduckgo.py +++ b/searx/engines/duckduckgo.py @@ -18,7 +18,7 @@ from searx.utils import html_to_text # engine dependent config categories = ['general'] paging = True -locale = 'us-en' +language_support = True # search-url url = 'https://duckduckgo.com/html?{query}&s={offset}' @@ -34,8 +34,13 @@ content_xpath = './/div[@class="snippet"]//text()' def request(query, params): offset = (params['pageno'] - 1) * 30 + if params['language'] == 'all': + locale = 'en-us' + else: + locale = params['language'].replace('_','-').lower() + params['url'] = url.format( - query=urlencode({'q': query, 'l': locale}), + query=urlencode({'q': query, 'kl': locale}), offset=offset) return params