Browse Source

[mod] google: support for showing the answer source url

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Markus Heiser 1 year ago
parent
commit
e2744520f8
1 changed files with 7 additions and 5 deletions
  1. 7 5
      searx/engines/google.py

+ 7 - 5
searx/engines/google.py

@@ -331,11 +331,13 @@ def response(resp):
 
 
     # results --> answer
     # results --> answer
     answer_list = eval_xpath(dom, '//div[contains(@class, "LGOjhe")]')
     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
     # parse results