133 lang, region = (params[
"language"].split(
"-") + [
None])[:2]
134 lang = yahoo_languages.get(lang,
"any")
136 offset = (params[
'pageno'] - 1) * 7 + 1
137 age, btf = time_range_dict.get(params[
'time_range'], (
'',
''))
144 'vl':
'lang_' + lang,
153 domain = region2domain.get(region)
155 domain = lang2domain.get(lang,
'%s.search.yahoo.com' % lang)
156 params[
'url'] =
'https://%s/search?%s' % (domain, args)
157 params[
'domain'] = domain
183 dom = html.fromstring(resp.text)
185 url_xpath =
'.//div[contains(@class,"compTitle")]/h3/a/@href'
186 title_xpath =
'.//h3//a/@aria-label'
188 domain = resp.search_params[
'domain']
189 if domain ==
"search.yahoo.com":
190 url_xpath =
'.//div[contains(@class,"compTitle")]/a/@href'
191 title_xpath =
'.//div[contains(@class,"compTitle")]/a/h3/span'
194 for result
in eval_xpath_list(dom,
'//div[contains(@class,"algo-sr")]'):
195 url = eval_xpath_getindex(result, url_xpath, 0, default=
None)
200 title = eval_xpath_getindex(result, title_xpath, 0, default=
'')
201 title: str = extract_text(title)
202 content = eval_xpath_getindex(result,
'.//div[contains(@class, "compText")]', 0, default=
'')
203 content: str = extract_text(content, allow_none=
True)
211 'title':
" ".join(html_to_text(title).strip().split()),
212 'content':
" ".join(html_to_text(content).strip().split()),
216 for suggestion
in eval_xpath_list(dom,
'//div[contains(@class, "AlsoTry")]//table//a'):
218 results.append({
'suggestion': extract_text(suggestion)})