mirror of https://github.com/searx/searx
[fix] use english as default language in bing
If no language is specified, bing returns results with multiple languages for one query which isn't really useful. Setting english as default insted if nothing.
This commit is contained in:
parent
79ceb13577
commit
6bf9c398a7
|
@ -33,8 +33,11 @@ def request(query, params):
|
|||
offset = (params['pageno'] - 1) * 10 + 1
|
||||
|
||||
if params['language'] != 'all':
|
||||
query = u'language:{} {}'.format(params['language'].split('-')[0].upper(),
|
||||
query.decode('utf-8')).encode('utf-8')
|
||||
lang = params['language'].split('-')[0].upper()
|
||||
else:
|
||||
lang = 'EN'
|
||||
|
||||
query = u'language:{} {}'.format(lang, query.decode('utf-8')).encode('utf-8')
|
||||
|
||||
search_path = search_string.format(
|
||||
query=urlencode({'q': query}),
|
||||
|
|
|
@ -19,7 +19,7 @@ class TestBingEngine(SearxTestCase):
|
|||
|
||||
dicto['language'] = 'all'
|
||||
params = bing.request(query, dicto)
|
||||
self.assertTrue('language' not in params['url'])
|
||||
self.assertTrue('language' in params['url'])
|
||||
|
||||
def test_response(self):
|
||||
self.assertRaises(AttributeError, bing.response, None)
|
||||
|
|
Loading…
Reference in New Issue