91 for result
in eval_xpath_list(dom, results_xpath):
94 'url': extract_text(eval_xpath(result, url_xpath)),
95 'title': extract_text(eval_xpath(result, title_xpath)),
96 'content': extract_text(eval_xpath(result, content_xpath)),
100 for suggestion
in eval_xpath(dom, suggestion_xpath):
101 results.append({
'suggestion': extract_text(suggestion)})
109 for result
in eval_xpath_list(dom, image_results_xpath):
112 'template':
'images.html',
113 'url': extract_text(eval_xpath(result, image_url_xpath)),
114 'title': extract_text(eval_xpath(result, image_title_xpath)),
115 'img_src': base_url + extract_text(eval_xpath(result, image_img_src_xpath)),
126 for result
in eval_xpath_list(dom, news_results_xpath):
129 'url': extract_text(eval_xpath(result, news_url_xpath)),
130 'title': extract_text(eval_xpath(result, news_title_xpath)),
131 'content': extract_text(eval_xpath(result, news_content_xpath)),
155 from searx
import network
157 from babel
import Locale, UnknownLocaleError
160 resp = network.get(base_url +
"/preferences", headers={
'Accept-Language':
'en-US,en;q=0.5'})
161 dom = html.fromstring(resp.text)
163 languages = eval_xpath_list(dom, f
'//select[@name="{language_param}"]/option/@value')
165 engine_traits.custom[
'language_all'] = languages[0]
167 for code
in languages[1:]:
168 with contextlib.suppress(UnknownLocaleError):
169 locale = Locale(code)
170 engine_traits.languages[locale.language] = code
172 regions = eval_xpath_list(dom, f
'//select[@name="{region_param}"]/option/@value')
174 engine_traits.custom[
'region_all'] = regions[1]
176 for code
in regions[2:]:
177 for locale
in get_official_locales(code, engine_traits.languages):
178 engine_traits.regions[region_tag(locale)] = code