Skip to content

Commit

Permalink
[fix] engine yahoo: HTML tags are included in result titles
Browse files Browse the repository at this point in the history
- searxng#3790

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
  • Loading branch information
Markus authored and Bnyro committed Sep 3, 2024
1 parent 94a1f39 commit 21bfb49
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions searx/engines/yahoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
eval_xpath_getindex,
eval_xpath_list,
extract_text,
html_to_text,
)
from searx.enginelib.traits import EngineTraits

Expand Down Expand Up @@ -133,12 +134,20 @@ def response(resp):
url = parse_url(url)

title = eval_xpath_getindex(result, './/h3//a/@aria-label', 0, default='')
title = extract_text(title)
title: str = extract_text(title)
content = eval_xpath_getindex(result, './/div[contains(@class, "compText")]', 0, default='')
content = extract_text(content, allow_none=True)
content: str = extract_text(content, allow_none=True)

# append result
results.append({'url': url, 'title': title, 'content': content})
results.append(
{
'url': url,
# title sometimes contains HTML tags / see
# https://github.com/searxng/searxng/issues/3790
'title': " ".join(html_to_text(title).strip().split()),
'content': " ".join(html_to_text(content).strip().split()),
}
)

for suggestion in eval_xpath_list(dom, '//div[contains(@class, "AlsoTry")]//table//a'):
# append suggestion
Expand Down

0 comments on commit 21bfb49

Please sign in to comment.