diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2023-08-16 08:50:51 +0200 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarIT.de> | 2023-08-18 19:07:14 +0200 |
commit | e2744520f856603699f6bb489c28f433a803719c (patch) | |
tree | 4cf2b25c8231489d46ebe3c9c0979c6024716720 /searx/engines/google.py | |
parent | 5ec7df34808d0fe9f057347116b3abf463e5fa6d (diff) | |
download | searxng-e2744520f856603699f6bb489c28f433a803719c.tar.gz searxng-e2744520f856603699f6bb489c28f433a803719c.zip |
[mod] google: support for showing the answer source url
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/engines/google.py')
-rw-r--r-- | searx/engines/google.py | 12 |
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 |