diff options
author | marc <a01200356@itesm.mx> | 2016-11-05 20:51:38 -0600 |
---|---|---|
committer | marc <a01200356@itesm.mx> | 2016-12-13 19:58:10 -0600 |
commit | f62ce21f50b540315a708ebfbf36878ddec9d1c4 (patch) | |
tree | 79f69b171e8d2d08fa30aa32a3592286622f9fcc /searx/engines/bing.py | |
parent | 92c6e88ad3e5ba57bd6e2ba64d0c38e8fd72ea09 (diff) | |
download | searxng-f62ce21f50b540315a708ebfbf36878ddec9d1c4.tar.gz searxng-f62ce21f50b540315a708ebfbf36878ddec9d1c4.zip |
[mod] fetch supported languages for several engines
utils/fetch_languages.py gets languages supported by each engine and
generates engines_languages.json with each engine's supported language.
Diffstat (limited to 'searx/engines/bing.py')
-rw-r--r-- | searx/engines/bing.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/searx/engines/bing.py b/searx/engines/bing.py index 052b66448..354003399 100644 --- a/searx/engines/bing.py +++ b/searx/engines/bing.py @@ -15,12 +15,14 @@ from urllib import urlencode from lxml import html +from requests import get from searx.engines.xpath import extract_text # engine dependent config categories = ['general'] paging = True language_support = True +supported_languages_url = 'https://www.bing.com/account/general' # search-url base_url = 'https://www.bing.com/' @@ -81,3 +83,16 @@ def response(resp): # return results return results + + +# get supported languages from their site +def fetch_supported_languages(): + supported_languages = [] + response = get(supported_languages_url) + dom = html.fromstring(response.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 |