From 3b2a2e28fa826246e52332510f976ba460f00e25 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 16 Aug 2023 08:50:51 +0200 Subject: [PATCH] [mod] google: support for showing the answer source url Signed-off-by: Markus Heiser --- searx/engines/google.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/searx/engines/google.py b/searx/engines/google.py index d06c0558a..9b976a17b 100644 --- a/searx/engines/google.py +++ b/searx/engines/google.py @@ -331,11 +331,13 @@ def response(resp): # results --> answer answer_list = eval_xpath(dom, '//div[contains(@class, "LGOjhe")]') - if answer_list: - answer_list = [_.xpath("normalize-space()") for _ in answer_list] - results.append({'answer': ' '.join(answer_list)}) - else: - logger.debug("did not find 'answer'") + for item in answer_list: + results.append( + { + 'answer': item.xpath("normalize-space()"), + 'url': (eval_xpath(item, '../..//a/@href') + [None])[0], + } + ) # parse results