We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Bug: bing engine crashes sometimes
**Version of SearXNG, commit number if you are using on master branch and stipulate if you forked SearXNG**
Repository: https://github.com/searxng/searxng
Branch: master
Version: 2023.01.08-4e735b28

**How did you install SearXNG?**
Docker
**What happened?**
Bing searches sometimes don't work.

**How To Reproduce**
`!bi certbot` (does not work at all for me)  
`!bi current events` (works ~50% of the time)

**Expected behavior**
Search works

**Screenshots & Logs**
```
2023-01-08 13:07:27,885 WARNING:searx.engines.bing: ErrorContext('searx/engines/bing.py', 89, "link = eval_xpath(result, './/h2/a')[0]", 'IndexError', None, ()) False
2023-01-08 13:07:27,885 ERROR:searx.engines.bing: exception : list index out of range
Traceback (most recent call last):
  File "/usr/local/searxng/searx/search/processors/online.py", line 160, in search
    search_results = self._search_basic(query, params)
  File "/usr/local/searxng/searx/search/processors/online.py", line 148, in _search_basic
    return self.engine.response(response)
  File "/usr/local/searxng/searx/engines/bing.py", line 89, in response
    link = eval_xpath(result, './/h2/a')[0]
IndexError: list index out of range
```

**Additional context**
Many searches *do* work.

Reproducible on some*, but not most, public instances running `2023.01.08-4e735b28`. At least using the specific repro searches above.

\* https://search.rhscz.eu , https://xo.wtf , out of the 7 running the current version

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `searx/engines/bing.py`
Content:
```
1 # SPDX-License-Identifier: AGPL-3.0-or-later
2 # lint: pylint
3 """Bing (Web)
4 
5 - https://github.com/searx/searx/issues/2019#issuecomment-648227442
6 """
7 # pylint: disable=too-many-branches
8 
9 import re
10 from urllib.parse import urlencode, urlparse, parse_qs
11 from lxml import html
12 from searx.utils import eval_xpath, extract_text, eval_xpath_list, match_language
13 from searx.network import multi_requests, Request
14 
15 about = {
16     "website": 'https://www.bing.com',
17     "wikidata_id": 'Q182496',
18     "official_api_documentation": 'https://www.microsoft.com/en-us/bing/apis/bing-web-search-api',
19     "use_official_api": False,
20     "require_api_key": False,
21     "results": 'HTML',
22 }
23 
24 # engine dependent config
25 categories = ['general', 'web']
26 paging = True
27 time_range_support = False
28 safesearch = False
29 send_accept_language_header = True
30 supported_languages_url = 'https://www.bing.com/account/general'
31 language_aliases = {}
32 
33 # search-url
34 base_url = 'https://www.bing.com/'
35 
36 # initial query:     https://www.bing.com/search?q=foo&search=&form=QBLH
37 inital_query = 'search?{query}&search=&form=QBLH'
38 
39 # following queries: https://www.bing.com/search?q=foo&search=&first=11&FORM=PERE
40 page_query = 'search?{query}&search=&first={offset}&FORM=PERE'
41 
42 
43 def _get_offset_from_pageno(pageno):
44     return (pageno - 1) * 10 + 1
45 
46 
47 def request(query, params):
48 
49     offset = _get_offset_from_pageno(params.get('pageno', 1))
50 
51     # logger.debug("params['pageno'] --> %s", params.get('pageno'))
52     # logger.debug("          offset --> %s", offset)
53 
54     search_string = page_query
55     if offset == 1:
56         search_string = inital_query
57 
58     if params['language'] == 'all':
59         lang = 'EN'
60     else:
61         lang = match_language(params['language'], supported_languages, language_aliases)
62 
63     query = 'language:{} {}'.format(lang.split('-')[0].upper(), query)
64 
65     search_path = search_string.format(query=urlencode({'q': query}), offset=offset)
66 
67     if offset > 1:
68         referer = base_url + inital_query.format(query=urlencode({'q': query}))
69         params['headers']['Referer'] = referer
70         logger.debug("headers.Referer --> %s", referer)
71 
72     params['url'] = base_url + search_path
73     params['headers']['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
74     return params
75 
76 
77 def response(resp):
78     results = []
79     result_len = 0
80 
81     dom = html.fromstring(resp.text)
82 
83     # parse results again if nothing is found yet
84 
85     url_to_resolve = []
86     url_to_resolve_index = []
87     for i, result in enumerate(eval_xpath_list(dom, '//li[contains(@class, "b_algo")]')):
88 
89         link = eval_xpath(result, './/h2/a')[0]
90         url = link.attrib.get('href')
91         title = extract_text(link)
92 
93         # Make sure that the element is free of <a href> links and <span class='algoSlug_icon'>
94         content = eval_xpath(result, '(.//p)[1]')
95         for p in content:
96             for e in p.xpath('.//a'):
97                 e.getparent().remove(e)
98             for e in p.xpath('.//span[@class="algoSlug_icon"]'):
99                 e.getparent().remove(e)
100         content = extract_text(content)
101 
102         # get the real URL either using the URL shown to user or following the Bing URL
103         if url.startswith('https://www.bing.com/ck/a?'):
104             url_cite = extract_text(eval_xpath(result, './/div[@class="b_attribution"]/cite'))
105             # Bing can shorten the URL either at the end or in the middle of the string
106             if (
107                 url_cite.startswith('https://')
108                 and '…' not in url_cite
109                 and '...' not in url_cite
110                 and '›' not in url_cite
111             ):
112                 # no need for an additional HTTP request
113                 url = url_cite
114             else:
115                 # resolve the URL with an additional HTTP request
116                 url_to_resolve.append(url.replace('&ntb=1', '&ntb=F'))
117                 url_to_resolve_index.append(i)
118                 url = None  # remove the result if the HTTP Bing redirect raise an exception
119 
120         # append result
121         results.append({'url': url, 'title': title, 'content': content})
122 
123     # resolve all Bing redirections in parallel
124     request_list = [
125         Request.get(u, allow_redirects=False, headers=resp.search_params['headers']) for u in url_to_resolve
126     ]
127     response_list = multi_requests(request_list)
128     for i, redirect_response in enumerate(response_list):
129         if not isinstance(redirect_response, Exception):
130             results[url_to_resolve_index[i]]['url'] = redirect_response.headers['location']
131 
132     # get number_of_results
133     try:
134         result_len_container = "".join(eval_xpath(dom, '//span[@class="sb_count"]//text()'))
135         if "-" in result_len_container:
136 
137             # Remove the part "from-to" for paginated request ...
138             result_len_container = result_len_container[result_len_container.find("-") * 2 + 2 :]
139 
140         result_len_container = re.sub('[^0-9]', '', result_len_container)
141 
142         if len(result_len_container) > 0:
143             result_len = int(result_len_container)
144 
145     except Exception as e:  # pylint: disable=broad-except
146         logger.debug('result error :\n%s', e)
147 
148     if result_len and _get_offset_from_pageno(resp.search_params.get("pageno", 0)) > result_len:
149         return []
150 
151     results.append({'number_of_results': result_len})
152     return results
153 
154 
155 # get supported languages from their site
156 def _fetch_supported_languages(resp):
157 
158     lang_tags = set()
159 
160     dom = html.fromstring(resp.text)
161     lang_links = eval_xpath(dom, '//div[@id="language-section"]//li')
162 
163     for _li in lang_links:
164 
165         href = eval_xpath(_li, './/@href')[0]
166         (_scheme, _netloc, _path, _params, query, _fragment) = urlparse(href)
167         query = parse_qs(query, keep_blank_values=True)
168 
169         # fmt: off
170         setlang = query.get('setlang', [None, ])[0]
171         # example: 'mn-Cyrl-MN' --> '['mn', 'Cyrl-MN']
172         lang, nation = (setlang.split('-', maxsplit=1) + [None,])[:2]  # fmt: skip
173         # fmt: on
174 
175         tag = lang + '-' + nation if nation else lang
176         lang_tags.add(tag)
177 
178     return list(lang_tags)
179
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/searx/engines/bing.py b/searx/engines/bing.py
--- a/searx/engines/bing.py
+++ b/searx/engines/bing.py
@@ -9,7 +9,7 @@
 import re
 from urllib.parse import urlencode, urlparse, parse_qs
 from lxml import html
-from searx.utils import eval_xpath, extract_text, eval_xpath_list, match_language
+from searx.utils import eval_xpath, extract_text, eval_xpath_list, match_language, eval_xpath_getindex
 from searx.network import multi_requests, Request
 
 about = {
@@ -84,9 +84,12 @@
 
     url_to_resolve = []
     url_to_resolve_index = []
-    for i, result in enumerate(eval_xpath_list(dom, '//li[contains(@class, "b_algo")]')):
+    i = 0
+    for result in eval_xpath_list(dom, '//ol[@id="b_results"]/li[contains(@class, "b_algo")]'):
 
-        link = eval_xpath(result, './/h2/a')[0]
+        link = eval_xpath_getindex(result, './/h2/a', 0, None)
+        if link is None:
+            continue
         url = link.attrib.get('href')
         title = extract_text(link)
 
@@ -119,6 +122,8 @@
 
         # append result
         results.append({'url': url, 'title': title, 'content': content})
+        # increment result pointer for the next iteration in this loop
+        i += 1
 
     # resolve all Bing redirections in parallel
     request_list = [

{"golden_diff": "diff --git a/searx/engines/bing.py b/searx/engines/bing.py\n--- a/searx/engines/bing.py\n+++ b/searx/engines/bing.py\n@@ -9,7 +9,7 @@\n import re\n from urllib.parse import urlencode, urlparse, parse_qs\n from lxml import html\n-from searx.utils import eval_xpath, extract_text, eval_xpath_list, match_language\n+from searx.utils import eval_xpath, extract_text, eval_xpath_list, match_language, eval_xpath_getindex\n from searx.network import multi_requests, Request\n \n about = {\n@@ -84,9 +84,12 @@\n \n     url_to_resolve = []\n     url_to_resolve_index = []\n-    for i, result in enumerate(eval_xpath_list(dom, '//li[contains(@class, \"b_algo\")]')):\n+    i = 0\n+    for result in eval_xpath_list(dom, '//ol[@id=\"b_results\"]/li[contains(@class, \"b_algo\")]'):\n \n-        link = eval_xpath(result, './/h2/a')[0]\n+        link = eval_xpath_getindex(result, './/h2/a', 0, None)\n+        if link is None:\n+            continue\n         url = link.attrib.get('href')\n         title = extract_text(link)\n \n@@ -119,6 +122,8 @@\n \n         # append result\n         results.append({'url': url, 'title': title, 'content': content})\n+        # increment result pointer for the next iteration in this loop\n+        i += 1\n \n     # resolve all Bing redirections in parallel\n     request_list = [\n", "issue": "Bug: bing engine crashes sometimes\n**Version of SearXNG, commit number if you are using on master branch and stipulate if you forked SearXNG**\r\nRepository: https://github.com/searxng/searxng\r\nBranch: master\r\nVersion: 2023.01.08-4e735b28\r\n\r\n**How did you install SearXNG?**\r\nDocker\r\n**What happened?**\r\nBing searches sometimes don't work.\r\n\r\n**How To Reproduce**\r\n`!bi certbot` (does not work at all for me)  \r\n`!bi current events` (works ~50% of the time)\r\n\r\n**Expected behavior**\r\nSearch works\r\n\r\n**Screenshots & Logs**\r\n```\r\n2023-01-08 13:07:27,885 WARNING:searx.engines.bing: ErrorContext('searx/engines/bing.py', 89, \"link = eval_xpath(result, './/h2/a')[0]\", 'IndexError', None, ()) False\r\n2023-01-08 13:07:27,885 ERROR:searx.engines.bing: exception : list index out of range\r\nTraceback (most recent call last):\r\n  File \"/usr/local/searxng/searx/search/processors/online.py\", line 160, in search\r\n    search_results = self._search_basic(query, params)\r\n  File \"/usr/local/searxng/searx/search/processors/online.py\", line 148, in _search_basic\r\n    return self.engine.response(response)\r\n  File \"/usr/local/searxng/searx/engines/bing.py\", line 89, in response\r\n    link = eval_xpath(result, './/h2/a')[0]\r\nIndexError: list index out of range\r\n```\r\n\r\n**Additional context**\r\nMany searches *do* work.\r\n\r\nReproducible on some*, but not most, public instances running `2023.01.08-4e735b28`. At least using the specific repro searches above.\r\n\r\n\\* https://search.rhscz.eu , https://xo.wtf , out of the 7 running the current version\n", "before_files": [{"content": "# SPDX-License-Identifier: AGPL-3.0-or-later\n# lint: pylint\n\"\"\"Bing (Web)\n\n- https://github.com/searx/searx/issues/2019#issuecomment-648227442\n\"\"\"\n# pylint: disable=too-many-branches\n\nimport re\nfrom urllib.parse import urlencode, urlparse, parse_qs\nfrom lxml import html\nfrom searx.utils import eval_xpath, extract_text, eval_xpath_list, match_language\nfrom searx.network import multi_requests, Request\n\nabout = {\n    \"website\": 'https://www.bing.com',\n    \"wikidata_id\": 'Q182496',\n    \"official_api_documentation\": 'https://www.microsoft.com/en-us/bing/apis/bing-web-search-api',\n    \"use_official_api\": False,\n    \"require_api_key\": False,\n    \"results\": 'HTML',\n}\n\n# engine dependent config\ncategories = ['general', 'web']\npaging = True\ntime_range_support = False\nsafesearch = False\nsend_accept_language_header = True\nsupported_languages_url = 'https://www.bing.com/account/general'\nlanguage_aliases = {}\n\n# search-url\nbase_url = 'https://www.bing.com/'\n\n# initial query:     https://www.bing.com/search?q=foo&search=&form=QBLH\ninital_query = 'search?{query}&search=&form=QBLH'\n\n# following queries: https://www.bing.com/search?q=foo&search=&first=11&FORM=PERE\npage_query = 'search?{query}&search=&first={offset}&FORM=PERE'\n\n\ndef _get_offset_from_pageno(pageno):\n    return (pageno - 1) * 10 + 1\n\n\ndef request(query, params):\n\n    offset = _get_offset_from_pageno(params.get('pageno', 1))\n\n    # logger.debug(\"params['pageno'] --> %s\", params.get('pageno'))\n    # logger.debug(\"          offset --> %s\", offset)\n\n    search_string = page_query\n    if offset == 1:\n        search_string = inital_query\n\n    if params['language'] == 'all':\n        lang = 'EN'\n    else:\n        lang = match_language(params['language'], supported_languages, language_aliases)\n\n    query = 'language:{} {}'.format(lang.split('-')[0].upper(), query)\n\n    search_path = search_string.format(query=urlencode({'q': query}), offset=offset)\n\n    if offset > 1:\n        referer = base_url + inital_query.format(query=urlencode({'q': query}))\n        params['headers']['Referer'] = referer\n        logger.debug(\"headers.Referer --> %s\", referer)\n\n    params['url'] = base_url + search_path\n    params['headers']['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'\n    return params\n\n\ndef response(resp):\n    results = []\n    result_len = 0\n\n    dom = html.fromstring(resp.text)\n\n    # parse results again if nothing is found yet\n\n    url_to_resolve = []\n    url_to_resolve_index = []\n    for i, result in enumerate(eval_xpath_list(dom, '//li[contains(@class, \"b_algo\")]')):\n\n        link = eval_xpath(result, './/h2/a')[0]\n        url = link.attrib.get('href')\n        title = extract_text(link)\n\n        # Make sure that the element is free of <a href> links and <span class='algoSlug_icon'>\n        content = eval_xpath(result, '(.//p)[1]')\n        for p in content:\n            for e in p.xpath('.//a'):\n                e.getparent().remove(e)\n            for e in p.xpath('.//span[@class=\"algoSlug_icon\"]'):\n                e.getparent().remove(e)\n        content = extract_text(content)\n\n        # get the real URL either using the URL shown to user or following the Bing URL\n        if url.startswith('https://www.bing.com/ck/a?'):\n            url_cite = extract_text(eval_xpath(result, './/div[@class=\"b_attribution\"]/cite'))\n            # Bing can shorten the URL either at the end or in the middle of the string\n            if (\n                url_cite.startswith('https://')\n                and '\u2026' not in url_cite\n                and '...' not in url_cite\n                and '\u203a' not in url_cite\n            ):\n                # no need for an additional HTTP request\n                url = url_cite\n            else:\n                # resolve the URL with an additional HTTP request\n                url_to_resolve.append(url.replace('&ntb=1', '&ntb=F'))\n                url_to_resolve_index.append(i)\n                url = None  # remove the result if the HTTP Bing redirect raise an exception\n\n        # append result\n        results.append({'url': url, 'title': title, 'content': content})\n\n    # resolve all Bing redirections in parallel\n    request_list = [\n        Request.get(u, allow_redirects=False, headers=resp.search_params['headers']) for u in url_to_resolve\n    ]\n    response_list = multi_requests(request_list)\n    for i, redirect_response in enumerate(response_list):\n        if not isinstance(redirect_response, Exception):\n            results[url_to_resolve_index[i]]['url'] = redirect_response.headers['location']\n\n    # get number_of_results\n    try:\n        result_len_container = \"\".join(eval_xpath(dom, '//span[@class=\"sb_count\"]//text()'))\n        if \"-\" in result_len_container:\n\n            # Remove the part \"from-to\" for paginated request ...\n            result_len_container = result_len_container[result_len_container.find(\"-\") * 2 + 2 :]\n\n        result_len_container = re.sub('[^0-9]', '', result_len_container)\n\n        if len(result_len_container) > 0:\n            result_len = int(result_len_container)\n\n    except Exception as e:  # pylint: disable=broad-except\n        logger.debug('result error :\\n%s', e)\n\n    if result_len and _get_offset_from_pageno(resp.search_params.get(\"pageno\", 0)) > result_len:\n        return []\n\n    results.append({'number_of_results': result_len})\n    return results\n\n\n# get supported languages from their site\ndef _fetch_supported_languages(resp):\n\n    lang_tags = set()\n\n    dom = html.fromstring(resp.text)\n    lang_links = eval_xpath(dom, '//div[@id=\"language-section\"]//li')\n\n    for _li in lang_links:\n\n        href = eval_xpath(_li, './/@href')[0]\n        (_scheme, _netloc, _path, _params, query, _fragment) = urlparse(href)\n        query = parse_qs(query, keep_blank_values=True)\n\n        # fmt: off\n        setlang = query.get('setlang', [None, ])[0]\n        # example: 'mn-Cyrl-MN' --> '['mn', 'Cyrl-MN']\n        lang, nation = (setlang.split('-', maxsplit=1) + [None,])[:2]  # fmt: skip\n        # fmt: on\n\n        tag = lang + '-' + nation if nation else lang\n        lang_tags.add(tag)\n\n    return list(lang_tags)\n", "path": "searx/engines/bing.py"}], "after_files": [{"content": "# SPDX-License-Identifier: AGPL-3.0-or-later\n# lint: pylint\n\"\"\"Bing (Web)\n\n- https://github.com/searx/searx/issues/2019#issuecomment-648227442\n\"\"\"\n# pylint: disable=too-many-branches\n\nimport re\nfrom urllib.parse import urlencode, urlparse, parse_qs\nfrom lxml import html\nfrom searx.utils import eval_xpath, extract_text, eval_xpath_list, match_language, eval_xpath_getindex\nfrom searx.network import multi_requests, Request\n\nabout = {\n    \"website\": 'https://www.bing.com',\n    \"wikidata_id\": 'Q182496',\n    \"official_api_documentation\": 'https://www.microsoft.com/en-us/bing/apis/bing-web-search-api',\n    \"use_official_api\": False,\n    \"require_api_key\": False,\n    \"results\": 'HTML',\n}\n\n# engine dependent config\ncategories = ['general', 'web']\npaging = True\ntime_range_support = False\nsafesearch = False\nsend_accept_language_header = True\nsupported_languages_url = 'https://www.bing.com/account/general'\nlanguage_aliases = {}\n\n# search-url\nbase_url = 'https://www.bing.com/'\n\n# initial query:     https://www.bing.com/search?q=foo&search=&form=QBLH\ninital_query = 'search?{query}&search=&form=QBLH'\n\n# following queries: https://www.bing.com/search?q=foo&search=&first=11&FORM=PERE\npage_query = 'search?{query}&search=&first={offset}&FORM=PERE'\n\n\ndef _get_offset_from_pageno(pageno):\n    return (pageno - 1) * 10 + 1\n\n\ndef request(query, params):\n\n    offset = _get_offset_from_pageno(params.get('pageno', 1))\n\n    # logger.debug(\"params['pageno'] --> %s\", params.get('pageno'))\n    # logger.debug(\"          offset --> %s\", offset)\n\n    search_string = page_query\n    if offset == 1:\n        search_string = inital_query\n\n    if params['language'] == 'all':\n        lang = 'EN'\n    else:\n        lang = match_language(params['language'], supported_languages, language_aliases)\n\n    query = 'language:{} {}'.format(lang.split('-')[0].upper(), query)\n\n    search_path = search_string.format(query=urlencode({'q': query}), offset=offset)\n\n    if offset > 1:\n        referer = base_url + inital_query.format(query=urlencode({'q': query}))\n        params['headers']['Referer'] = referer\n        logger.debug(\"headers.Referer --> %s\", referer)\n\n    params['url'] = base_url + search_path\n    params['headers']['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'\n    return params\n\n\ndef response(resp):\n    results = []\n    result_len = 0\n\n    dom = html.fromstring(resp.text)\n\n    # parse results again if nothing is found yet\n\n    url_to_resolve = []\n    url_to_resolve_index = []\n    i = 0\n    for result in eval_xpath_list(dom, '//ol[@id=\"b_results\"]/li[contains(@class, \"b_algo\")]'):\n\n        link = eval_xpath_getindex(result, './/h2/a', 0, None)\n        if link is None:\n            continue\n        url = link.attrib.get('href')\n        title = extract_text(link)\n\n        # Make sure that the element is free of <a href> links and <span class='algoSlug_icon'>\n        content = eval_xpath(result, '(.//p)[1]')\n        for p in content:\n            for e in p.xpath('.//a'):\n                e.getparent().remove(e)\n            for e in p.xpath('.//span[@class=\"algoSlug_icon\"]'):\n                e.getparent().remove(e)\n        content = extract_text(content)\n\n        # get the real URL either using the URL shown to user or following the Bing URL\n        if url.startswith('https://www.bing.com/ck/a?'):\n            url_cite = extract_text(eval_xpath(result, './/div[@class=\"b_attribution\"]/cite'))\n            # Bing can shorten the URL either at the end or in the middle of the string\n            if (\n                url_cite.startswith('https://')\n                and '\u2026' not in url_cite\n                and '...' not in url_cite\n                and '\u203a' not in url_cite\n            ):\n                # no need for an additional HTTP request\n                url = url_cite\n            else:\n                # resolve the URL with an additional HTTP request\n                url_to_resolve.append(url.replace('&ntb=1', '&ntb=F'))\n                url_to_resolve_index.append(i)\n                url = None  # remove the result if the HTTP Bing redirect raise an exception\n\n        # append result\n        results.append({'url': url, 'title': title, 'content': content})\n        # increment result pointer for the next iteration in this loop\n        i += 1\n\n    # resolve all Bing redirections in parallel\n    request_list = [\n        Request.get(u, allow_redirects=False, headers=resp.search_params['headers']) for u in url_to_resolve\n    ]\n    response_list = multi_requests(request_list)\n    for i, redirect_response in enumerate(response_list):\n        if not isinstance(redirect_response, Exception):\n            results[url_to_resolve_index[i]]['url'] = redirect_response.headers['location']\n\n    # get number_of_results\n    try:\n        result_len_container = \"\".join(eval_xpath(dom, '//span[@class=\"sb_count\"]//text()'))\n        if \"-\" in result_len_container:\n\n            # Remove the part \"from-to\" for paginated request ...\n            result_len_container = result_len_container[result_len_container.find(\"-\") * 2 + 2 :]\n\n        result_len_container = re.sub('[^0-9]', '', result_len_container)\n\n        if len(result_len_container) > 0:\n            result_len = int(result_len_container)\n\n    except Exception as e:  # pylint: disable=broad-except\n        logger.debug('result error :\\n%s', e)\n\n    if result_len and _get_offset_from_pageno(resp.search_params.get(\"pageno\", 0)) > result_len:\n        return []\n\n    results.append({'number_of_results': result_len})\n    return results\n\n\n# get supported languages from their site\ndef _fetch_supported_languages(resp):\n\n    lang_tags = set()\n\n    dom = html.fromstring(resp.text)\n    lang_links = eval_xpath(dom, '//div[@id=\"language-section\"]//li')\n\n    for _li in lang_links:\n\n        href = eval_xpath(_li, './/@href')[0]\n        (_scheme, _netloc, _path, _params, query, _fragment) = urlparse(href)\n        query = parse_qs(query, keep_blank_values=True)\n\n        # fmt: off\n        setlang = query.get('setlang', [None, ])[0]\n        # example: 'mn-Cyrl-MN' --> '['mn', 'Cyrl-MN']\n        lang, nation = (setlang.split('-', maxsplit=1) + [None,])[:2]  # fmt: skip\n        # fmt: on\n\n        tag = lang + '-' + nation if nation else lang\n        lang_tags.add(tag)\n\n    return list(lang_tags)\n", "path": "searx/engines/bing.py"}]}