diff --git a/searx/engines/google.py b/searx/engines/google.py index 2fa638d73..0fdf2d4ae 100644 --- a/searx/engines/google.py +++ b/searx/engines/google.py @@ -112,6 +112,7 @@ title_xpath = './/h3' content_xpath = './/span[@class="st"]' content_misc_xpath = './/div[@class="f slp"]' suggestion_xpath = '//p[@class="_Bmc"]' +spelling_suggestion_xpath = '//a[@class="spell"]' # map : detail location map_address_xpath = './/div[@class="s"]//table//td[2]/span/text()' @@ -275,6 +276,9 @@ def response(resp): # append suggestion results.append({'suggestion': extract_text(suggestion)}) + for correction in dom.xpath(spelling_suggestion_xpath): + results.append({'correction': extract_text(correction)}) + # return results return results diff --git a/searx/results.py b/searx/results.py index 6062f8013..e262ec110 100644 --- a/searx/results.py +++ b/searx/results.py @@ -127,6 +127,7 @@ class ResultContainer(object): self.infoboxes = [] self.suggestions = set() self.answers = set() + self.corrections = set() self._number_of_results = [] self._ordered = False self.paging = False @@ -140,6 +141,9 @@ class ResultContainer(object): elif 'answer' in result: self.answers.add(result['answer']) results.remove(result) + elif 'correction' in result: + self.corrections.add(result['correction']) + results.remove(result) elif 'infobox' in result: self._merge_infobox(result) results.remove(result) diff --git a/searx/templates/oscar/results.html b/searx/templates/oscar/results.html index f5e95438d..11c950b9e 100644 --- a/searx/templates/oscar/results.html +++ b/searx/templates/oscar/results.html @@ -16,6 +16,18 @@