diff options
| author | Adam Tauber <asciimoo@gmail.com> | 2016-12-28 20:09:57 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-12-28 20:09:57 +0100 |
| commit | 9743bde25ef2ce6b765b8192aafcdc0a15739b17 (patch) | |
| tree | 00fd6b0b14773c0e20425d4a6478d67f244d64ed /searx/engines/bing.py | |
| parent | ea034fafa994227ea89662710901e73cb901e28c (diff) | |
| parent | 8bff42f049dcac77559beaf2932a47921feb1d49 (diff) | |
Merge pull request #748 from a01200356/languages
[mod] Allow users to search in most engine supported languages
Diffstat (limited to 'searx/engines/bing.py')
| -rw-r--r-- | searx/engines/bing.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/searx/engines/bing.py b/searx/engines/bing.py index 58db61251..b2ad7b6cf 100644 --- a/searx/engines/bing.py +++ b/searx/engines/bing.py @@ -21,6 +21,7 @@ from searx.engines.xpath import extract_text categories = ['general'] paging = True language_support = True +supported_languages_url = 'https://www.bing.com/account/general' # search-url base_url = 'https://www.bing.com/' @@ -32,7 +33,7 @@ def request(query, params): offset = (params['pageno'] - 1) * 10 + 1 if params['language'] != 'all': - query = u'language:{} {}'.format(params['language'].split('_')[0].upper(), + query = u'language:{} {}'.format(params['language'].split('-')[0].upper(), query.decode('utf-8')).encode('utf-8') search_path = search_string.format( @@ -81,3 +82,15 @@ def response(resp): # return results return results + + +# get supported languages from their site +def _fetch_supported_languages(resp): + supported_languages = [] + dom = html.fromstring(resp.text) + options = dom.xpath('//div[@id="limit-languages"]//input') + for option in options: + code = option.xpath('./@id')[0].replace('_', '-') + supported_languages.append(code) + + return supported_languages |