summaryrefslogtreecommitdiff
path: root/searx/engines/google.py
diff options
context:
space:
mode:
Diffstat (limited to 'searx/engines/google.py')
-rw-r--r--searx/engines/google.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/searx/engines/google.py b/searx/engines/google.py
index e1871c654..e322aa41b 100644
--- a/searx/engines/google.py
+++ b/searx/engines/google.py
@@ -59,11 +59,6 @@ filter_mapping = {0: 'off', 1: 'medium', 2: 'high'}
# specific xpath variables
# ------------------------
-results_xpath = './/div[contains(@jscontroller, "SC7lYd")]'
-title_xpath = './/a/h3[1]'
-href_xpath = './/a[h3]/@href'
-content_xpath = './/div[contains(@data-sncf, "1")]'
-
# Suggestions are links placed in a *card-section*, we extract only the text
# from the links not the links itself.
suggestion_xpath = '//div[contains(@class, "EIaa9b")]//a'
@@ -345,22 +340,27 @@ def response(resp):
# parse results
- for result in eval_xpath_list(dom, results_xpath): # pylint: disable=too-many-nested-blocks
+ for result in eval_xpath_list(dom, './/div[contains(@jscontroller, "SC7lYd")]'):
+ # pylint: disable=too-many-nested-blocks
try:
- title_tag = eval_xpath_getindex(result, title_xpath, 0, default=None)
+ title_tag = eval_xpath_getindex(result, './/a/h3[1]', 0, default=None)
if title_tag is None:
# this not one of the common google results *section*
logger.debug('ignoring item from the result_xpath list: missing title')
continue
title = extract_text(title_tag)
- url = eval_xpath_getindex(result, href_xpath, 0, None)
+ url = eval_xpath_getindex(result, './/a[h3]/@href', 0, None)
if url is None:
logger.debug('ignoring item from the result_xpath list: missing url of title "%s"', title)
continue
- content_nodes = eval_xpath(result, content_xpath)
+ content_nodes = eval_xpath(result, './/div[contains(@data-sncf, "1")]')
+ for item in content_nodes:
+ for script in item.xpath(".//script"):
+ script.getparent().remove(script)
+
content = extract_text(content_nodes)
if not content: