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