summaryrefslogtreecommitdiff
path: root/searx/engines
diff options
context:
space:
mode:
authorasciimoo <asciimoo@gmail.com>2013-11-13 19:33:09 +0100
committerasciimoo <asciimoo@gmail.com>2013-11-13 19:33:09 +0100
commite50a72b0e34a0c9d5d377f19dafcf717876ab6b0 (patch)
treeb01aa5a41a8e3084d52e54180706a409c148e2a2 /searx/engines
parent66ff28bb9deddcd2eb88186e45cc86d31587b636 (diff)
downloadsearxng-e50a72b0e34a0c9d5d377f19dafcf717876ab6b0.tar.gz
searxng-e50a72b0e34a0c9d5d377f19dafcf717876ab6b0.zip
[enh] suggestion support for xpath engine
Diffstat (limited to 'searx/engines')
-rw-r--r--searx/engines/xpath.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/searx/engines/xpath.py b/searx/engines/xpath.py
index 2743dc2a0..068f2ba61 100644
--- a/searx/engines/xpath.py
+++ b/searx/engines/xpath.py
@@ -8,6 +8,7 @@ search_url = None
url_xpath = None
content_xpath = None
title_xpath = None
+suggestion_xpath = ''
results_xpath = ''
def extract_url(xpath_results):
@@ -56,5 +57,8 @@ def response(resp):
for content, url, title in zip(dom.xpath(content_xpath), map(extract_url, dom.xpath(url_xpath)), dom.xpath(title_xpath)):
results.append({'url': url, 'title': title, 'content': content})
-
+ if not suggestion_xpath:
+ return results
+ for suggestion in dom.xpath(suggestion_xpath):
+ results.append({'suggestion': escape(''.join(suggestion.xpath('.//text()')))})
return results