diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2024-07-28 10:30:57 +0200 |
---|---|---|
committer | Bnyro <bnyro@tutanota.com> | 2024-07-28 19:00:51 +0200 |
commit | ee959ed9fc6bbe3da30876080117e9aafbba850f (patch) | |
tree | db5a35f04cbde2254ce77acfe0dfb2a5ca703c26 /searx/engines/geizhals.py | |
parent | 022898e50235815bda5c9387ad42da90a9eb18ff (diff) | |
download | searxng-ee959ed9fc6bbe3da30876080117e9aafbba850f.tar.gz searxng-ee959ed9fc6bbe3da30876080117e9aafbba850f.zip |
[fix] engine geizhals: if there are no offers, there is no best price
Fault pattern: if there are no offers, then an exception has been thrown:
IndexError: list index out of range
This patch makes the addition of “best price” dependent on whether one exists.
Closes: #3685
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/engines/geizhals.py')
-rw-r--r-- | searx/engines/geizhals.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/searx/engines/geizhals.py b/searx/engines/geizhals.py index eae110b20..4ada41919 100644 --- a/searx/engines/geizhals.py +++ b/searx/engines/geizhals.py @@ -86,12 +86,12 @@ def response(resp): 'title': extract_text(eval_xpath(result, ".//h3[contains(@class, 'listview__name')]")), 'content': ' | '.join(content), 'thumbnail': extract_text(eval_xpath(result, ".//img[contains(@class, 'listview__image')]/@src")), - 'price': "Bestes Angebot: " - + extract_text(eval_xpath(result, ".//a[contains(@class, 'listview__price-link')]")).split(" ")[1] - + "€", 'metadata': ', '.join(item for item in metadata if item), } + best_price = extract_text(eval_xpath(result, ".//a[contains(@class, 'listview__price-link')]")).split(" ") + if len(best_price) > 1: + item["price"] = f"Bestes Angebot: {best_price[1]}€" results.append(item) return results |