summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrant Lanham <contact@grantlanham.com>2024-07-08 15:16:53 -0400
committerMarkus Heiser <markus.heiser@darmarIT.de>2024-07-15 06:58:39 +0200
commit9a4fa7cc4f0339a1ea696f6fb7068fd6156f03e2 (patch)
treedcce202c714c4b8b66ed704cd8e0b14843760e17
parent2039060b640189e250020e6e17db10b0a0730e7e (diff)
downloadsearxng-9a4fa7cc4f0339a1ea696f6fb7068fd6156f03e2.tar.gz
searxng-9a4fa7cc4f0339a1ea696f6fb7068fd6156f03e2.zip
Update mullvad_leta.py to account for img_elem
A recent update from Mullvad Leta introduced the img_elem. This update broke the existing logic. Now, by checking the length of the dom_result to see if it was included in the return results, we can handle the logic accordingly.
-rw-r--r--searx/engines/mullvad_leta.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/searx/engines/mullvad_leta.py b/searx/engines/mullvad_leta.py
index a1e59d93b..7e2b590e8 100644
--- a/searx/engines/mullvad_leta.py
+++ b/searx/engines/mullvad_leta.py
@@ -128,7 +128,14 @@ def request(query: str, params: dict):
def extract_result(dom_result: list[html.HtmlElement]):
- [a_elem, h3_elem, p_elem] = dom_result
+ # Infoboxes sometimes appear in the beginning and will have a length of 0
+ if len(dom_result) == 3:
+ [a_elem, h3_elem, p_elem] = dom_result
+ elif len(dom_result) == 4:
+ [_, a_elem, h3_elem, p_elem] = dom_result
+ else:
+ return None
+
return {
'url': extract_text(a_elem.text),
'title': extract_text(h3_elem),
@@ -139,9 +146,9 @@ def extract_result(dom_result: list[html.HtmlElement]):
def extract_results(search_results: html.HtmlElement):
for search_result in search_results:
dom_result = eval_xpath_list(search_result, 'div/div/*')
- # sometimes an info box pops up, will need to filter that out
- if len(dom_result) == 3:
- yield extract_result(dom_result)
+ result = extract_result(dom_result)
+ if result is not None:
+ yield result
def response(resp: Response):