diff --git a/searx/engines/ahmia.py b/searx/engines/ahmia.py index 952462244..32170f2dc 100644 --- a/searx/engines/ahmia.py +++ b/searx/engines/ahmia.py @@ -39,7 +39,6 @@ url_xpath = './h4/a/@href' title_xpath = './h4/a[1]' content_xpath = './/p[1]' correction_xpath = '//*[@id="didYouMean"]//a' -number_of_results_xpath = '//*[@id="totalResults"]' name_token_xpath = '//form[@id="searchForm"]/input[@type="hidden"]/@name' value_token_xpath = '//form[@id="searchForm"]/input[@type="hidden"]/@value' @@ -107,14 +106,6 @@ def response(resp): for correction in eval_xpath_list(dom, correction_xpath): results.append({'correction': extract_text(correction)}) - # get number of results - number_of_results = eval_xpath(dom, number_of_results_xpath) - if number_of_results: - try: - results.append({'number_of_results': int(extract_text(number_of_results))}) - except: # pylint: disable=bare-except - pass - # Update the tokens to the newest ones token_str = _get_tokens(dom) CACHE.set('ahmia-tokens', token_str, expire=60 * 60) diff --git a/searx/engines/bing.py b/searx/engines/bing.py index 48537d679..cae89d24f 100644 --- a/searx/engines/bing.py +++ b/searx/engines/bing.py @@ -13,7 +13,6 @@ implementations are shared by other engines: """ import base64 -import re import typing as t from urllib.parse import parse_qs, urlencode, urlparse @@ -159,12 +158,6 @@ def response(resp: "SXNG_Response") -> list[dict[str, t.Any]]: results.append({"url": href, "title": title, "content": content}) - if results: - result_len_container = "".join(eval_xpath(dom, '//span[@class="sb_count"]//text()')) - result_len_container = re.sub(r"[^0-9]", "", result_len_container) - if result_len_container: - results.append({"number_of_results": int(result_len_container)}) - return results diff --git a/searx/engines/demo_offline.py b/searx/engines/demo_offline.py index d9e5d0eb5..26cd62554 100644 --- a/searx/engines/demo_offline.py +++ b/searx/engines/demo_offline.py @@ -109,7 +109,6 @@ def search(query: str, params: "RequestParams") -> EngineResults: kvmap=kvmap, ) ) - res.add(res.types.LegacyResult(number_of_results=count)) # cache counter value for 20sec CACHE.set("count", count, expire=20) diff --git a/searx/engines/discourse.py b/searx/engines/discourse.py index 97f4ef0cf..d7e1a5720 100644 --- a/searx/engines/discourse.py +++ b/searx/engines/discourse.py @@ -176,6 +176,4 @@ def response(resp): results.append(result) - results.append({'number_of_results': len(json_data['topics'])}) - return results diff --git a/searx/engines/duden.py b/searx/engines/duden.py index c2e758d6f..b422d8339 100644 --- a/searx/engines/duden.py +++ b/searx/engines/duden.py @@ -1,7 +1,6 @@ # SPDX-License-Identifier: AGPL-3.0-or-later """Duden""" -import re from urllib.parse import quote, urljoin from lxml import html from searx.utils import extract_text, eval_xpath, eval_xpath_list, eval_xpath_getindex @@ -51,13 +50,6 @@ def response(resp): dom = html.fromstring(resp.text) - number_of_results_element = eval_xpath_getindex( - dom, '//a[@class="active" and contains(@href,"/suchen/dudenonline")]/span/text()', 0, default=None - ) - if number_of_results_element is not None: - number_of_results_string = re.sub('[^0-9]', '', number_of_results_element) - results.append({'number_of_results': int(number_of_results_string)}) - for result in eval_xpath_list(dom, '//section[not(contains(@class, "essay"))]'): url = eval_xpath_getindex(result, './/h2/a', 0).get('href') url = urljoin(base_url, url) diff --git a/searx/engines/mongodb.py b/searx/engines/mongodb.py index a183cc17f..8c3f18bfa 100644 --- a/searx/engines/mongodb.py +++ b/searx/engines/mongodb.py @@ -93,7 +93,6 @@ def search(query, params) -> EngineResults: query = _client.find({key: q}).skip((params['pageno'] - 1) * results_per_page).limit(results_per_page) - res.add(res.types.LegacyResult(number_of_results=query.count())) for row in query: del row['_id'] kvmap = {str(k): str(v) for k, v in row.items()} diff --git a/searx/engines/searx_engine.py b/searx/engines/searx_engine.py index 1a67743f4..e0bb8133e 100644 --- a/searx/engines/searx_engine.py +++ b/searx/engines/searx_engine.py @@ -54,6 +54,4 @@ def response(resp): results.extend({'suggestion': s} for s in response_json['suggestions']) - results.append({'number_of_results': response_json['number_of_results']}) - return results diff --git a/searx/engines/tineye.py b/searx/engines/tineye.py index 2150e8f59..53c0f2861 100644 --- a/searx/engines/tineye.py +++ b/searx/engines/tineye.py @@ -211,8 +211,4 @@ def response(resp) -> EngineResults: # append number of results - number_of_results = json_data.get('num_matches') - if number_of_results: - results.append({'number_of_results': number_of_results}) - return results diff --git a/searx/result_types/_base.py b/searx/result_types/_base.py index e83be4382..3624d64ec 100644 --- a/searx/result_types/_base.py +++ b/searx/result_types/_base.py @@ -529,7 +529,7 @@ class LegacyResult(dict[str, t.Any]): # the img_src are equal. return hash(f"{self.template}|{self.url}|{self.img_src}") - if not any(cls in self for cls in ["suggestion", "correction", "infobox", "number_of_results", "engine_data"]): + if not any(cls in self for cls in ["suggestion", "correction", "infobox", "engine_data"]): # Ordinary url-results are equal if their values for template, # parsed_url (without schema) and img_src` are equal. diff --git a/searx/results.py b/searx/results.py index f3bac2eb7..01c80ae06 100644 --- a/searx/results.py +++ b/searx/results.py @@ -69,7 +69,6 @@ class ResultContainer: self.answers = AnswerSet() self.corrections = set() - self._number_of_results: list[int] = [] self.engine_data: dict[str, dict[str, str]] = defaultdict(dict) self._closed: bool = False self.paging: bool = False @@ -135,11 +134,6 @@ class ResultContainer: self._merge_infobox(result) continue - if "number_of_results" in result: - if self.on_result(result): - self._number_of_results.append(result["number_of_results"]) - continue - if "engine_data" in result: if self.on_result(result): if result.engine: @@ -252,25 +246,6 @@ class ResultContainer: self._main_results_sorted = gresults return self._main_results_sorted - @property - def number_of_results(self) -> int: - """Returns the average of results number, returns zero if the average - result number is smaller than the actual result count.""" - - if not self._closed: - log.error("call to ResultContainer.number_of_results before ResultContainer.close") - return 0 - - with self._lock: - resultnum_sum = sum(self._number_of_results) - if not resultnum_sum or not self._number_of_results: - return 0 - - average = int(resultnum_sum / len(self._number_of_results)) - if average < len(self.get_ordered_results()): - average = 0 - return average - def add_unresponsive_engine(self, engine_name: str, error_type: str, suspended: bool = False): with self._lock: if self._closed: diff --git a/searx/templates/simple/opensearch_response_rss.xml b/searx/templates/simple/opensearch_response_rss.xml index ab732aec2..ac36cd4b1 100644 --- a/searx/templates/simple/opensearch_response_rss.xml +++ b/searx/templates/simple/opensearch_response_rss.xml @@ -7,9 +7,7 @@ SearXNG search: {{ q|e }} {{ url_for('search', _external=True) }}?q={{ q|e }} Search results for "{{ q|e }}" - SearXNG - {{ number_of_results }} 1 - {{ number_of_results }}