forked from Ponysearch/Ponysearch
[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
2 changed files with 6 additions and 3 deletions
|
@ -33,8 +33,11 @@ def request(query, params):
|
||||||
offset = (params['pageno'] - 1) * 10 + 1
|
offset = (params['pageno'] - 1) * 10 + 1
|
||||||
|
|
||||||
if params['language'] != 'all':
|
if params['language'] != 'all':
|
||||||
query = u'language:{} {}'.format(params['language'].split('-')[0].upper(),
|
lang = params['language'].split('-')[0].upper()
|
||||||
query.decode('utf-8')).encode('utf-8')
|
else:
|
||||||
|
lang = 'EN'
|
||||||
|
|
||||||
|
query = u'language:{} {}'.format(lang, query.decode('utf-8')).encode('utf-8')
|
||||||
|
|
||||||
search_path = search_string.format(
|
search_path = search_string.format(
|
||||||
query=urlencode({'q': query}),
|
query=urlencode({'q': query}),
|
||||||
|
|
|
@ -19,7 +19,7 @@ class TestBingEngine(SearxTestCase):
|
||||||
|
|
||||||
dicto['language'] = 'all'
|
dicto['language'] = 'all'
|
||||||
params = bing.request(query, dicto)
|
params = bing.request(query, dicto)
|
||||||
self.assertTrue('language' not in params['url'])
|
self.assertTrue('language' in params['url'])
|
||||||
|
|
||||||
def test_response(self):
|
def test_response(self):
|
||||||
self.assertRaises(AttributeError, bing.response, None)
|
self.assertRaises(AttributeError, bing.response, None)
|
||||||
|
|
Loading…
Reference in a new issue