mirror of
				https://github.com/searxng/searxng
				synced 2024-01-01 19:24:07 +01:00 
			
		
		
		
	[enh] Add autocompleter from Brave
Raw response example: https://search.brave.com/api/suggest?q=how%20to:%20with%20j
Headers are needed in order to get a 200 response, thus Searx user-agent is used.
Other URL param could be  '&rich=false' or  '&rich=true'.
Cherry-pick: 71786bf9cb
			
			
This commit is contained in:
		
							parent
							
								
									f3d4b25e73
								
							
						
					
					
						commit
						b8c98c4c0d
					
				
					 1 changed files with 15 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -36,6 +36,20 @@ def get(*args, **kwargs):
 | 
			
		|||
    return http_get(*args, **kwargs)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def brave(query, lang):
 | 
			
		||||
    # brave search autocompleter
 | 
			
		||||
    url = 'https://search.brave.com/api/suggest?{query}'
 | 
			
		||||
    resp = get(url.format(query=urlencode({'q': query})))
 | 
			
		||||
 | 
			
		||||
    results = []
 | 
			
		||||
 | 
			
		||||
    if resp.ok:
 | 
			
		||||
        data = loads(resp.text)
 | 
			
		||||
        for item in data[1]:
 | 
			
		||||
            results.append(item)
 | 
			
		||||
    return results
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def dbpedia(query, lang):
 | 
			
		||||
    # dbpedia autocompleter, no HTTPS
 | 
			
		||||
    autocomplete_url = 'https://lookup.dbpedia.org/api/search.asmx/KeywordSearch?'
 | 
			
		||||
| 
						 | 
				
			
			@ -128,6 +142,7 @@ backends = {
 | 
			
		|||
    'swisscows': swisscows,
 | 
			
		||||
    'qwant': qwant,
 | 
			
		||||
    'wikipedia': wikipedia,
 | 
			
		||||
    'brave': brave,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue