Просмотр исходного кода

[enh] suggestion support for xpath engine

asciimoo 11 лет назад
Родитель
Сommit
e50a72b0e3
1 измененных файлов: 5 добавлений и 1 удалений
  1. 5
    1
      searx/engines/xpath.py

+ 5
- 1
searx/engines/xpath.py Просмотреть файл

@@ -8,6 +8,7 @@ search_url    = None
8 8
 url_xpath     = None
9 9
 content_xpath = None
10 10
 title_xpath   = None
11
+suggestion_xpath = ''
11 12
 results_xpath = ''
12 13
 
13 14
 def extract_url(xpath_results):
@@ -56,5 +57,8 @@ def response(resp):
56 57
         for content, url, title in zip(dom.xpath(content_xpath), map(extract_url, dom.xpath(url_xpath)), dom.xpath(title_xpath)):
57 58
             results.append({'url': url, 'title': title, 'content': content})
58 59
 
59
-
60
+    if not suggestion_xpath:
61
+        return results
62
+    for suggestion in dom.xpath(suggestion_xpath):
63
+        results.append({'suggestion': escape(''.join(suggestion.xpath('.//text()')))})
60 64
     return results