forked from zaclys/searxng
		
	Merge pull request #660 from davidar/ma
Add Microsoft Academic search engine
This commit is contained in:
		
						commit
						d6fe37f9ff
					
				
					 2 changed files with 32 additions and 7 deletions
				
			
		|  | @ -6,7 +6,8 @@ search_url = None | ||||||
| url_query = None | url_query = None | ||||||
| content_query = None | content_query = None | ||||||
| title_query = None | title_query = None | ||||||
| # suggestion_xpath = '' | suggestion_query = '' | ||||||
|  | results_query = '' | ||||||
| 
 | 
 | ||||||
| # parameters for engines with paging support | # parameters for engines with paging support | ||||||
| # | # | ||||||
|  | @ -90,12 +91,23 @@ def request(query, params): | ||||||
| 
 | 
 | ||||||
| def response(resp): | def response(resp): | ||||||
|     results = [] |     results = [] | ||||||
| 
 |  | ||||||
|     json = loads(resp.text) |     json = loads(resp.text) | ||||||
| 
 |     if results_query: | ||||||
|     urls = query(json, url_query) |         for result in query(json, results_query)[0]: | ||||||
|     contents = query(json, content_query) |             url = query(result, url_query)[0] | ||||||
|     titles = query(json, title_query) |             title = query(result, title_query)[0] | ||||||
|     for url, title, content in zip(urls, titles, contents): |             content = query(result, content_query)[0] | ||||||
|             results.append({'url': url, 'title': title, 'content': content}) |             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 |     return results | ||||||
|  |  | ||||||
|  | @ -287,6 +287,19 @@ engines: | ||||||
|     timeout : 6.0 |     timeout : 6.0 | ||||||
|     disabled : True |     disabled : True | ||||||
| 
 | 
 | ||||||
|  |   - name : microsoft academic | ||||||
|  |     engine : json_engine | ||||||
|  |     paging : True | ||||||
|  |     search_url : https://academic.microsoft.com/api/search/GetEntityResults?query=%40{query}%40&filters=&offset={pageno}&limit=8&correlationId=undefined | ||||||
|  |     results_query : results | ||||||
|  |     url_query : u | ||||||
|  |     title_query : dn | ||||||
|  |     content_query : d | ||||||
|  |     page_size : 8 | ||||||
|  |     first_page_num : 0 | ||||||
|  |     categories : science | ||||||
|  |     shortcut : ma | ||||||
|  | 
 | ||||||
|   - name : mixcloud |   - name : mixcloud | ||||||
|     engine : mixcloud |     engine : mixcloud | ||||||
|     shortcut : mc |     shortcut : mc | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Adam Tauber
						Adam Tauber