mirror of
				https://github.com/searxng/searxng
				synced 2024-01-01 19:24:07 +01:00 
			
		
		
		
	[enh] add seznam autocomplete
This commit is contained in:
		
							parent
							
								
									09230bfad9
								
							
						
					
					
						commit
						de4af2fefd
					
				
					 2 changed files with 18 additions and 1 deletions
				
			
		| 
						 | 
					@ -85,6 +85,22 @@ def google(query, lang):
 | 
				
			||||||
    return results
 | 
					    return results
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def seznam(query, _lang):
 | 
				
			||||||
 | 
					    # seznam search autocompleter
 | 
				
			||||||
 | 
					    url = 'https://suggest.seznam.cz/fulltext/cs?{query}'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    resp = get(url.format(query=urlencode(
 | 
				
			||||||
 | 
					        {'phrase': query, 'cursorPosition': len(query), 'format': 'json-2', 'highlight': '1', 'count': '6'}
 | 
				
			||||||
 | 
					    )))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if not resp.ok:
 | 
				
			||||||
 | 
					        return []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    data = resp.json()
 | 
				
			||||||
 | 
					    return [''.join(
 | 
				
			||||||
 | 
					        [part.get('text', '') for part in item.get('text', [])]
 | 
				
			||||||
 | 
					    ) for item in data.get('result', []) if item.get('itemType', None) == 'ItemType.TEXT']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def startpage(query, lang):
 | 
					def startpage(query, lang):
 | 
				
			||||||
    # startpage autocompleter
 | 
					    # startpage autocompleter
 | 
				
			||||||
    lui = ENGINES_LANGUAGES['startpage'].get(lang, 'english')
 | 
					    lui = ENGINES_LANGUAGES['startpage'].get(lang, 'english')
 | 
				
			||||||
| 
						 | 
					@ -133,6 +149,7 @@ backends = {
 | 
				
			||||||
    'dbpedia': dbpedia,
 | 
					    'dbpedia': dbpedia,
 | 
				
			||||||
    'duckduckgo': duckduckgo,
 | 
					    'duckduckgo': duckduckgo,
 | 
				
			||||||
    'google': google,
 | 
					    'google': google,
 | 
				
			||||||
 | 
					    'seznam': seznam,
 | 
				
			||||||
    'startpage': startpage,
 | 
					    'startpage': startpage,
 | 
				
			||||||
    'swisscows': swisscows,
 | 
					    'swisscows': swisscows,
 | 
				
			||||||
    'qwant': qwant,
 | 
					    'qwant': qwant,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,7 +15,7 @@ search:
 | 
				
			||||||
  # Filter results. 0: None, 1: Moderate, 2: Strict
 | 
					  # Filter results. 0: None, 1: Moderate, 2: Strict
 | 
				
			||||||
  safe_search: 0
 | 
					  safe_search: 0
 | 
				
			||||||
  # Existing autocomplete backends: "dbpedia", "duckduckgo", "google",
 | 
					  # Existing autocomplete backends: "dbpedia", "duckduckgo", "google",
 | 
				
			||||||
  # "startpage", "swisscows", "qwant", "wikipedia" - leave blank to turn it off
 | 
					  # "seznam", "startpage", "swisscows", "qwant", "wikipedia" - leave blank to turn it off
 | 
				
			||||||
  # by default.
 | 
					  # by default.
 | 
				
			||||||
  autocomplete: ""
 | 
					  autocomplete: ""
 | 
				
			||||||
  # Default search language - leave blank to detect from browser information or
 | 
					  # Default search language - leave blank to detect from browser information or
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue