52 """Returns a set of :ref:`request params <engine request online>` or ``None``
53 if request is not supported.
55 params = super().
get_params(search_query, engine_category)
63 params[
'headers'][
'User-Agent'] = gen_useragent()
66 if self.
engineengine.send_accept_language_header
and search_query.locale:
67 ac_lang = search_query.locale.language
68 if search_query.locale.territory:
69 ac_lang =
"%s-%s,%s;q=0.9,*;q=0.5" % (
70 search_query.locale.language,
71 search_query.locale.territory,
72 search_query.locale.language,
74 params[
'headers'][
'Accept-Language'] = ac_lang
76 self.
logger.debug(
'HTTP Accept-Language: %s', params[
'headers'].get(
'Accept-Language',
''))
82 request_args = dict(headers=params[
'headers'], cookies=params[
'cookies'], auth=params[
'auth'])
88 verify = params.get(
'verify')
89 if verify
is not None:
90 request_args[
'verify'] = params[
'verify']
93 max_redirects = params.get(
'max_redirects')
95 request_args[
'max_redirects'] = max_redirects
98 if 'allow_redirects' in params:
99 request_args[
'allow_redirects'] = params[
'allow_redirects']
102 soft_max_redirects = params.get(
'soft_max_redirects', max_redirects
or 0)
105 request_args[
'raise_for_httperror'] = params.get(
'raise_for_httperror',
True)
108 if params[
'method'] ==
'GET':
109 req = searx.network.get
111 req = searx.network.post
113 request_args[
'data'] = params[
'data']
116 response = req(params[
'url'], **request_args)
119 if len(response.history) > soft_max_redirects:
122 status_code = str(response.status_code
or '')
123 reason = response.reason_phrase
or ''
124 hostname = response.url.host
127 '{} redirects, maximum: {}'.
format(len(response.history), soft_max_redirects),
128 (status_code, reason, hostname),
153 def search(self, query, params, result_container, start_time, timeout_limit):
165 except ssl.SSLError
as e:
169 except (httpx.TimeoutException, asyncio.TimeoutError)
as e:
173 "HTTP requests timeout (search duration : {0} s, timeout: {1} s) : {2}".
format(
174 default_timer() - start_time, timeout_limit, e.__class__.__name__
177 except (httpx.HTTPError, httpx.StreamError)
as e:
181 "requests exception (search duration : {0} s, timeout: {1} s) : {2}".
format(
182 default_timer() - start_time, timeout_limit, e
185 except SearxEngineCaptchaException
as e:
187 self.
logger.exception(
'CAPTCHA')
188 except SearxEngineTooManyRequestsException
as e:
190 self.
logger.exception(
'Too many requests')
191 except SearxEngineAccessDeniedException
as e:
193 self.
logger.exception(
'SearXNG is blocked')
194 except Exception
as e: