|
@@ -6,7 +6,8 @@ search_url = None
|
6
|
6
|
url_query = None
|
7
|
7
|
content_query = None
|
8
|
8
|
title_query = None
|
9
|
|
-# suggestion_xpath = ''
|
|
9
|
+suggestion_query = ''
|
|
10
|
+results_query = ''
|
10
|
11
|
|
11
|
12
|
# parameters for engines with paging support
|
12
|
13
|
#
|
|
@@ -90,12 +91,23 @@ def request(query, params):
|
90
|
91
|
|
91
|
92
|
def response(resp):
|
92
|
93
|
results = []
|
93
|
|
-
|
94
|
94
|
json = loads(resp.text)
|
95
|
|
-
|
96
|
|
- urls = query(json, url_query)
|
97
|
|
- contents = query(json, content_query)
|
98
|
|
- titles = query(json, title_query)
|
99
|
|
- for url, title, content in zip(urls, titles, contents):
|
100
|
|
- results.append({'url': url, 'title': title, 'content': content})
|
|
95
|
+ if results_query:
|
|
96
|
+ for result in query(json, results_query)[0]:
|
|
97
|
+ url = query(result, url_query)[0]
|
|
98
|
+ title = query(result, title_query)[0]
|
|
99
|
+ content = query(result, content_query)[0]
|
|
100
|
+ results.append({'url': url, 'title': title, 'content': content})
|
|
101
|
+ else:
|
|
102
|
+ for url, title, content in zip(
|
|
103
|
+ query(json, url_query),
|
|
104
|
+ query(json, title_query),
|
|
105
|
+ query(json, content_query)
|
|
106
|
+ ):
|
|
107
|
+ results.append({'url': url, 'title': title, 'content': content})
|
|
108
|
+
|
|
109
|
+ if not suggestion_query:
|
|
110
|
+ return results
|
|
111
|
+ for suggestion in query(json, suggestion_query):
|
|
112
|
+ results.append({'suggestion': suggestion})
|
101
|
113
|
return results
|