mirror of
				https://github.com/searxng/searxng.git
				synced 2025-11-04 03:27:06 -05:00 
			
		
		
		
	Merge branch 'master' into add_ccctv_to_settings
This commit is contained in:
		
						commit
						e6d69b082f
					
				
							
								
								
									
										57
									
								
								searx/engines/searx_engine.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								searx/engines/searx_engine.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,57 @@
 | 
			
		||||
"""
 | 
			
		||||
 Searx (all)
 | 
			
		||||
 | 
			
		||||
 @website     https://github.com/asciimoo/searx
 | 
			
		||||
 @provide-api yes (https://asciimoo.ithub.io/searx/dev/search_api.html)
 | 
			
		||||
 | 
			
		||||
 @using-api   yes
 | 
			
		||||
 @results     JSON
 | 
			
		||||
 @stable      yes (using api)
 | 
			
		||||
 @parse       url, title, content
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
from json import loads
 | 
			
		||||
from searx.engines import categories as searx_categories
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
categories = searx_categories.keys()
 | 
			
		||||
 | 
			
		||||
# search-url
 | 
			
		||||
instance_urls = []
 | 
			
		||||
instance_index = 0
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# do search-request
 | 
			
		||||
def request(query, params):
 | 
			
		||||
    global instance_index
 | 
			
		||||
    params['url'] = instance_urls[instance_index % len(instance_urls)]
 | 
			
		||||
    params['method'] = 'POST'
 | 
			
		||||
 | 
			
		||||
    instance_index += 1
 | 
			
		||||
 | 
			
		||||
    params['data'] = {
 | 
			
		||||
        'q': query,
 | 
			
		||||
        'pageno': params['pageno'],
 | 
			
		||||
        'language': params['language'],
 | 
			
		||||
        'time_range': params['time_range'],
 | 
			
		||||
        'category': params['category'],
 | 
			
		||||
        'format': 'json'
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return params
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# get response from search-request
 | 
			
		||||
def response(resp):
 | 
			
		||||
 | 
			
		||||
    response_json = loads(resp.text)
 | 
			
		||||
    results = response_json['results']
 | 
			
		||||
 | 
			
		||||
    for i in ('answers', 'infoboxes'):
 | 
			
		||||
        results.extend(response_json[i])
 | 
			
		||||
 | 
			
		||||
    results.extend({'suggestion': s} for s in response_json['suggestions'])
 | 
			
		||||
 | 
			
		||||
    results.append({'number_of_results': response_json['number_of_results']})
 | 
			
		||||
 | 
			
		||||
    return results
 | 
			
		||||
@ -174,6 +174,7 @@ engines:
 | 
			
		||||
    suggestion_xpath : //a[@class="crossreference"]
 | 
			
		||||
    first_page_num : 0
 | 
			
		||||
    shortcut : et
 | 
			
		||||
    disabled : True
 | 
			
		||||
 | 
			
		||||
# api-key required: http://www.faroo.com/hp/api/api.html#key
 | 
			
		||||
#  - name : faroo
 | 
			
		||||
@ -451,6 +452,14 @@ engines:
 | 
			
		||||
    shortcut : scc
 | 
			
		||||
    disabled : True
 | 
			
		||||
 | 
			
		||||
#  - name : searx
 | 
			
		||||
#    engine : searx_engine
 | 
			
		||||
#    shortcut : se
 | 
			
		||||
#    instance_urls :
 | 
			
		||||
#        - http://127.0.0.1:8888/
 | 
			
		||||
#        - ...
 | 
			
		||||
#    disabled : True
 | 
			
		||||
 | 
			
		||||
  - name : spotify
 | 
			
		||||
    engine : spotify
 | 
			
		||||
    shortcut : stf
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user