From 27385e789853b41e81493301bf5538616e484c90 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Fri, 12 Aug 2022 18:37:46 +0200 Subject: [PATCH] [mod] qwant - add safesearch option Closes: https://github.com/searxng/searxng/issues/1640 Signed-off-by: Markus Heiser --- searx/engines/qwant.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/searx/engines/qwant.py b/searx/engines/qwant.py index 47956fc97..6de2176d0 100644 --- a/searx/engines/qwant.py +++ b/searx/engines/qwant.py @@ -52,6 +52,9 @@ paging = True supported_languages_url = about['website'] qwant_categ = None # web|news|inages|videos +safesearch = True +safe_search_map = {0: '&safesearch=0', 1: '&safesearch=1', 2: '&safesearch=2'} + # fmt: off qwant_news_locales = [ 'ca_ad', 'ca_es', 'ca_fr', 'co_fr', 'de_at', 'de_ch', 'de_de', 'en_au', @@ -95,6 +98,9 @@ def request(query, params): q_locale = get_engine_locale(params['language'], supported_languages, default='en_US') params['url'] += '&locale=' + q_locale + # add safesearch option + params['url'] += safe_search_map.get(params['safesearch'], '') + params['raise_for_httperror'] = False return params