summaryrefslogtreecommitdiff
path: root/searx/engines/bing.py
diff options
context:
space:
mode:
Diffstat (limited to 'searx/engines/bing.py')
-rw-r--r--searx/engines/bing.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/searx/engines/bing.py b/searx/engines/bing.py
index 2e58d0293..c6d41782b 100644
--- a/searx/engines/bing.py
+++ b/searx/engines/bing.py
@@ -16,12 +16,14 @@
from lxml import html
from searx.engines.xpath import extract_text
from searx.url_utils import urlencode
+from searx.utils import match_language
# engine dependent config
categories = ['general']
paging = True
language_support = True
supported_languages_url = 'https://www.bing.com/account/general'
+language_aliases = {'zh-CN': 'zh-CHS', 'zh-TW': 'zh-CHT', 'zh-HK': 'zh-CHT'}
# search-url
base_url = 'https://www.bing.com/'
@@ -32,9 +34,9 @@ search_string = 'search?{query}&first={offset}'
def request(query, params):
offset = (params['pageno'] - 1) * 10 + 1
- lang = params['language'].split('-')[0].upper()
+ lang = match_language(params['language'], supported_languages, language_aliases)
- query = u'language:{} {}'.format(lang, query.decode('utf-8')).encode('utf-8')
+ query = u'language:{} {}'.format(lang.split('-')[0].upper(), query.decode('utf-8')).encode('utf-8')
search_path = search_string.format(
query=urlencode({'q': query}),