[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:
Adam Tauber 2016-12-30 18:17:14 +01:00
parent 79ceb13577
commit 6bf9c398a7
2 changed files with 6 additions and 3 deletions

View File

@ -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}),

View File

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