99def request(query: str, params: dict[str, t.Any]):
101 eng_region = traits.get_region(params[
'searxng_locale'], traits.all_locale)
102 eng_lang = get_ddg_lang(traits, params[
'searxng_locale'])
105 params[
'cookies'][
'ad'] = eng_lang
106 params[
'cookies'][
'ah'] = eng_region
107 params[
'cookies'][
'l'] = eng_region
108 logger.debug(
"cookies: %s", params[
'cookies'])
110 params[
"url"] = base_url.format(query=quote(query), lang=eng_lang.split(
'_')[0])
117 if resp.text.strip() ==
"ddg_spice_forecast();":
120 json_data = loads(resp.text[resp.text.find(
'\n') + 1 : resp.text.rfind(
'\n') - 2])
122 geoloc = weather.GeoLocation.by_query(resp.search_params[
"query"])
124 weather_answer = EngineResults.types.WeatherAnswer(
126 service=
"duckduckgo weather",
129 for forecast
in json_data[
'forecastHourly'][
'hours']:
130 forecast_time = date_parser.parse(forecast[
'forecastStart'])
133 weather_answer.forecasts.append(forecast_data)
135 res.add(weather_answer)