diff options
author | Alexandre Flament <alex@al-f.net> | 2021-03-01 09:06:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-01 09:06:37 +0100 |
commit | f77983e174ec45913f32482210e36c3cb94cf810 (patch) | |
tree | 8d6a34b6c5bff5d96eca7ed7b7e5f327e9ca5e01 /searx/engines | |
parent | 5f6ac3afa2c8f2030fb72612a566d3d639896dab (diff) | |
parent | d6681fd33b31cd058f2ff15e035828251773acae (diff) | |
download | searxng-f77983e174ec45913f32482210e36c3cb94cf810.tar.gz searxng-f77983e174ec45913f32482210e36c3cb94cf810.zip |
Merge pull request #2602 from MarcAbonce/fix-bing-fetch-languages
Fix fetch_languages for Bing
Diffstat (limited to 'searx/engines')
-rw-r--r-- | searx/engines/__init__.py | 8 | ||||
-rw-r--r-- | searx/engines/wikipedia.py | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py index 80d5d18fc..9ece10964 100644 --- a/searx/engines/__init__.py +++ b/searx/engines/__init__.py @@ -27,7 +27,7 @@ from searx import settings from searx import logger from searx.data import ENGINES_LANGUAGES from searx.poolrequests import get, get_proxy_cycles -from searx.utils import load_module, match_language, get_engine_from_settings +from searx.utils import load_module, match_language, get_engine_from_settings, gen_useragent logger = logger.getChild('engines') @@ -131,8 +131,12 @@ def load_engine(engine_data): # assign language fetching method if auxiliary method exists if hasattr(engine, '_fetch_supported_languages'): + headers = { + 'User-Agent': gen_useragent(), + 'Accept-Language': 'ja-JP,ja;q=0.8,en-US;q=0.5,en;q=0.3', # bing needs a non-English language + } setattr(engine, 'fetch_supported_languages', - lambda: engine._fetch_supported_languages(get(engine.supported_languages_url))) + lambda: engine._fetch_supported_languages(get(engine.supported_languages_url, headers=headers))) engine.stats = { 'sent_search_count': 0, # sent search diff --git a/searx/engines/wikipedia.py b/searx/engines/wikipedia.py index 2adfefa69..da867c81e 100644 --- a/searx/engines/wikipedia.py +++ b/searx/engines/wikipedia.py @@ -106,6 +106,6 @@ def _fetch_supported_languages(resp): articles = int(td[4].xpath('./a/b')[0].text.replace(',', '')) # exclude languages with too few articles if articles >= 100: - supported_languages[code] = {"name": name, "english_name": english_name, "articles": articles} + supported_languages[code] = {"name": name, "english_name": english_name} return supported_languages |