1
0
mirror of https://github.com/searx/searx synced 2024-11-29 21:50:11 +01:00

[fix] google answers: normalize space of the answers.

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser 2021-06-21 16:46:08 +02:00 committed by Noémi Ványi
parent 412677d495
commit 98a63058e5

View File

@ -254,9 +254,10 @@ def response(resp):
dom = html.fromstring(resp.text)
# results --> answer
answer = eval_xpath(dom, '//div[contains(@class, "LGOjhe")]//text()')
if answer:
results.append({'answer': ' '.join(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'")