summaryrefslogtreecommitdiff
path: root/searx/engines/json_engine.py
diff options
context:
space:
mode:
authorDavid A Roberts <d@vidr.cc>2016-08-12 20:15:27 +1000
committerDavid A Roberts <d@vidr.cc>2016-08-12 20:19:10 +1000
commit61fe5daf305f60169cf1fc0c4794aff37ec8765f (patch)
tree9c2c740364c072bb92638ed3bf40534e157139b9 /searx/engines/json_engine.py
parent31866d9f3357683949971b62d44e01b3d73befe1 (diff)
downloadsearxng-61fe5daf305f60169cf1fc0c4794aff37ec8765f.tar.gz
searxng-61fe5daf305f60169cf1fc0c4794aff37ec8765f.zip
Add Microsoft Academic search engine
Diffstat (limited to 'searx/engines/json_engine.py')
-rw-r--r--searx/engines/json_engine.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/searx/engines/json_engine.py b/searx/engines/json_engine.py
index cd5e3a7e1..a824c38e5 100644
--- a/searx/engines/json_engine.py
+++ b/searx/engines/json_engine.py
@@ -6,7 +6,8 @@ search_url = None
url_query = None
content_query = None
title_query = None
-# suggestion_xpath = ''
+suggestion_query = ''
+results_query = ''
# parameters for engines with paging support
#
@@ -90,12 +91,23 @@ def request(query, params):
def response(resp):
results = []
-
json = loads(resp.text)
-
- urls = query(json, url_query)
- contents = query(json, content_query)
- titles = query(json, title_query)
- for url, title, content in zip(urls, titles, contents):
- results.append({'url': url, 'title': title, 'content': content})
+ if results_query:
+ for result in query(json, results_query)[0]:
+ url = query(result, url_query)[0]
+ title = query(result, title_query)[0]
+ content = query(result, content_query)[0]
+ results.append({'url': url, 'title': title, 'content': content})
+ else:
+ for url, title, content in zip(
+ query(json, url_query),
+ query(json, title_query),
+ query(json, content_query)
+ ):
+ results.append({'url': url, 'title': title, 'content': content})
+
+ if not suggestion_query:
+ return results
+ for suggestion in query(json, suggestion_query):
+ results.append({'suggestion': suggestion})
return results