logo

searx

Unnamed repository; edit this file 'description' to name the repository.
commit: 6bf9c398a7ed5f3fb624f2ea35a9d00fe016811d
parent: 79ceb13577fcc83eabe642a4ed6dd793b7bf0d4b
Author: Adam Tauber <asciimoo@gmail.com>
Date:   Fri, 30 Dec 2016 18:17:14 +0100

[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.

Diffstat:

searx/engines/bing.py | 7+++++--
tests/unit/engines/test_bing.py | 2+-
2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/searx/engines/bing.py b/searx/engines/bing.py @@ -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}), diff --git a/tests/unit/engines/test_bing.py b/tests/unit/engines/test_bing.py @@ -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)