From bf56ec4fb1199ab46feeacb8a045d28b287baf47 Mon Sep 17 00:00:00 2001 From: Dalf Date: Sun, 5 Jan 2014 13:58:17 +0100 Subject: [PATCH] [mod] bing and duckduckgo engines : add / rename locale parameter --- engines.cfg_sample | 3 ++- searx/engines/bing.py | 4 ++-- searx/engines/duckduckgo.py | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/engines.cfg_sample b/engines.cfg_sample index e2668eeb..27131e9d 100644 --- a/engines.cfg_sample +++ b/engines.cfg_sample @@ -5,7 +5,7 @@ number_of_results = 1 [bing] engine = bing -language = en-us +locale = en-us [cc] engine=currency_convert @@ -20,6 +20,7 @@ engine = duckduckgo_definitions [duckduckgo] engine = duckduckgo +locale = en-us [flickr] engine = flickr diff --git a/searx/engines/bing.py b/searx/engines/bing.py index 1002a29c..6b0bf5a3 100644 --- a/searx/engines/bing.py +++ b/searx/engines/bing.py @@ -4,11 +4,11 @@ from cgi import escape base_url = 'http://www.bing.com/' search_string = 'search?{query}' -language = 'en-us' # see http://msdn.microsoft.com/en-us/library/dd251064.aspx +locale = 'en-US' # see http://msdn.microsoft.com/en-us/library/dd251064.aspx def request(query, params): - search_path = search_string.format(query=urlencode({'q': query, 'setmkt': language})) + search_path = search_string.format(query=urlencode({'q': query, 'setmkt': locale})) #if params['category'] == 'images': # params['url'] = base_url + 'images/' + search_path params['url'] = base_url + search_path diff --git a/searx/engines/duckduckgo.py b/searx/engines/duckduckgo.py index d591854a..4bf77097 100644 --- a/searx/engines/duckduckgo.py +++ b/searx/engines/duckduckgo.py @@ -3,10 +3,11 @@ from urllib import urlencode from searx.utils import html_to_text url = 'https://duckduckgo.com/' -search_url = url + 'd.js?{query}&l=us-en&p=1&s=0' +search_url = url + 'd.js?{query}&p=1&s=0' +locale = 'us-en' def request(query, params): - params['url'] = search_url.format(query=urlencode({'q': query})) + params['url'] = search_url.format(query=urlencode({'q': query, 'l': locale})) return params