SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
xpath engine: change raise_for_httperror to no_result_for_http_status
Alexandre FLAMENTdd0887be186d
diff --git a/searx/engines/xpath.py b/searx/engines/xpath.pyindex 97656705a..f9528e92d 100644--- a/searx/engines/xpath.py+++ b/searx/engines/xpath.py@@ -22,6 +22,7 @@ from urllib.parse import urlencodefrom lxml import htmlfrom searx.utils import extract_text, extract_url, eval_xpath, eval_xpath_list+from searx.network import raise_for_httperrorsearch_url = None"""@@ -60,9 +61,14 @@ lang_all = 'en''''Replacement ``{lang}`` in :py:obj:`search_url` if language ``all`` isselected.'''-raise_for_httperror = True-'''True by default: raise an exception if the HTTP code of response is ``>=-300``'''++no_result_for_http_status = []+'''Return empty result for these HTTP status codes instead of throwing an error.++.. code:: yaml++ no_result_for_http_status: []+'''soft_max_redirects = 0'''Maximum redirects, soft limit. Record an error but don't stop the engine'''@@ -179,12 +185,19 @@ def request(query, params):params['url'] = search_url.format(**fargs)params['soft_max_redirects'] = soft_max_redirects- params['raise_for_httperror'] = raise_for_httperror++ params['raise_for_httperror'] = False+return params-def response(resp):+def response(resp): # pylint: disable=too-many-branches'''Scrap *results* from the response (see :ref:`engine results`).'''+ if no_result_for_http_status and resp.status_code in no_result_for_http_status:+ return []++ raise_for_httperror(resp)+results = []dom = html.fromstring(resp.text)is_onion = 'onions' in categoriesdiff --git a/searx/settings.yml b/searx/settings.ymlindex f83c104fd..5587ed51a 100644--- a/searx/settings.yml+++ b/searx/settings.yml@@ -1808,7 +1808,7 @@ engines:url_xpath: //div[@class="upper-synonyms"]/a/@hrefcontent_xpath: //div[@class="synonyms-list-group"]title_xpath: //div[@class="upper-synonyms"]/a- raise_for_httperror: false+ no_result_for_http_status: [404]about:website: https://www.woxikon.de/wikidata_id: # No Wikidata ID