77 lang = locale_aliases.get(params[
'language'],
None)
79 lang = params[
'language'].split(
'-')[0]
80 lang = traits.get_language(lang, traits.all_locale)
82 offset = (params[
'pageno'] - 1) * 7 + 1
83 age, btf = time_range_dict.get(params[
'time_range'], (
'',
''))
99 domain = lang2domain.get(lang,
'%s.search.yahoo.com' % lang)
100 params[
'url'] =
'https://%s/search?%s' % (domain, args)
127 dom = html.fromstring(resp.text)
130 for result
in eval_xpath_list(dom,
'//div[contains(@class,"algo-sr")]'):
131 url = eval_xpath_getindex(result,
'.//h3/a/@href', 0, default=
None)
136 title = eval_xpath_getindex(result,
'.//h3//a/@aria-label', 0, default=
'')
137 title: str = extract_text(title)
138 content = eval_xpath_getindex(result,
'.//div[contains(@class, "compText")]', 0, default=
'')
139 content: str = extract_text(content, allow_none=
True)
147 'title':
" ".join(html_to_text(title).strip().split()),
148 'content':
" ".join(html_to_text(content).strip().split()),
152 for suggestion
in eval_xpath_list(dom,
'//div[contains(@class, "AlsoTry")]//table//a'):
154 results.append({
'suggestion': extract_text(suggestion)})
160 """Fetch languages from yahoo"""
164 from searx
import network
167 engine_traits.all_locale =
'any'
169 resp = network.get(
'https://search.yahoo.com/preferences/languages')
171 print(
"ERROR: response from yahoo is not OK.")
173 dom = html.fromstring(resp.text)
174 offset = len(
'lang_')
176 eng2sxng = {
'zh_chs':
'zh_Hans',
'zh_cht':
'zh_Hant'}
178 for val
in eval_xpath_list(dom,
'//div[contains(@class, "lang-item")]/input/@value'):
179 eng_tag = val[offset:]
182 sxng_tag = language_tag(babel.Locale.parse(eng2sxng.get(eng_tag, eng_tag)))
183 except babel.UnknownLocaleError:
184 print(
'ERROR: unknown language --> %s' % eng_tag)
187 conflict = engine_traits.languages.get(sxng_tag)
189 if conflict != eng_tag:
190 print(
"CONFLICT: babel %s --> %s, %s" % (sxng_tag, conflict, eng_tag))
192 engine_traits.languages[sxng_tag] = eng_tag