[mod] bing and duckduckgo engines : add / rename locale parameter

This commit is contained in:
Dalf 2014-01-05 13:58:17 +01:00
parent 49c85fce51
commit bf56ec4fb1
3 changed files with 7 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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