commit: 64b75e6d829d9fc8b742c94499b5219c12a053d7
parent 1e99cf2a0e541a3d2df0104d64fadf955bbccc20
Author: dalf <alex@al-f.net>
Date: Sun, 7 Sep 2014 22:52:13 +0200
[enh] duckduckgo engine: add language support
Diffstat:
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git 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