summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2023-08-16 08:50:51 +0200
committerMarkus Heiser <markus.heiser@darmarIT.de>2023-08-18 19:07:14 +0200
commite2744520f856603699f6bb489c28f433a803719c (patch)
tree4cf2b25c8231489d46ebe3c9c0979c6024716720
parent5ec7df34808d0fe9f057347116b3abf463e5fa6d (diff)
downloadsearxng-e2744520f856603699f6bb489c28f433a803719c.tar.gz
searxng-e2744520f856603699f6bb489c28f433a803719c.zip
[mod] google: support for showing the answer source url
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
-rw-r--r--searx/engines/google.py12
1 files 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