summaryrefslogtreecommitdiff
path: root/searx/engines
diff options
context:
space:
mode:
authorSisyphus <sisyphus@ohmyopen.com>2026-06-28 15:48:04 +0900
committerBnyro <bnyro@tutanota.com>2026-06-29 20:25:23 +0200
commit28d388576433668ab46b2691978732fb4933d696 (patch)
tree6bcd635e07ef63bc7912163be249e7fecdc8c7d5 /searx/engines
parentb084194c095ab6d573103527fd9c6e84ba0810de (diff)
[fix] naver: update HTML parsing for redesigned Naver search results page
Naver redesigned their search results page, replacing the old CSS classes (lst_total, link_tit, total_dsc_wrap, api_txt_lines) with a new layout using fds-web-doc-root containers and sds-comps design system. Updated parse_general(): - Result container: fds-web-doc-root + fds-web-normal-doc-root - Title: sds-comps-text-type-headline1 span - URL: first external http link (with try/except guard) - Content: sds-comps-text-type-body1 span - Thumbnail: profile-thumbnail img src - Added guard: skip results without title or URL
Diffstat (limited to 'searx/engines')
-rw-r--r--searx/engines/naver.py40
1 files changed, 26 insertions, 14 deletions
diff --git a/searx/engines/naver.py b/searx/engines/naver.py
index ca8d79f7e..74b4ec54d 100644
--- a/searx/engines/naver.py
+++ b/searx/engines/naver.py
@@ -99,23 +99,35 @@ def parse_general(data):
dom = html.fromstring(data)
- for item in eval_xpath_list(dom, "//ul[contains(@class, 'lst_total')]/li[contains(@class, 'bx')]"):
- thumbnail = None
+ for item in eval_xpath_list(dom, "//div[contains(@class, 'fds-web-normal-doc-root')]"):
+ thumbnail = extract_text(
+ eval_xpath(
+ item,
+ ".//div[contains(@class, 'sds-comps-image') and not(contains(@class, 'sds-comps-image-circle'))]/img/@src",
+ )
+ )
+
+ title = extract_text(eval_xpath(item, ".//span[contains(@class, 'sds-comps-text-type-headline1')]"))
+
+ url = None
try:
- thumbnail = eval_xpath_getindex(item, ".//div[contains(@class, 'thumb_single')]//img/@data-lazysrc", 0)
+ url = eval_xpath_getindex(
+ item, ".//a[starts-with(@href, 'http') and not(contains(@href, 'keep.naver.com'))]/@href", 0
+ )
except (ValueError, TypeError, SearxEngineXPathException):
pass
- results.add(
- MainResult(
- title=extract_text(eval_xpath(item, ".//a[contains(@class, 'link_tit')]")),
- url=eval_xpath_getindex(item, ".//a[contains(@class, 'link_tit')]/@href", 0),
- content=extract_text(
- eval_xpath(item, ".//div[contains(@class, 'total_dsc_wrap')]//a[contains(@class, 'api_txt_lines')]")
- ),
- thumbnail=thumbnail,
+ content = extract_text(eval_xpath(item, ".//span[contains(@class, 'sds-comps-text-type-body1')]"))
+
+ if title and url:
+ results.add(
+ MainResult(
+ title=title,
+ url=url,
+ content=content or "",
+ thumbnail=thumbnail or "",
+ )
)
- )
return results
@@ -173,7 +185,7 @@ def parse_news(data):
title=title,
url=url,
content=content,
- thumbnail=thumbnail,
+ thumbnail=thumbnail or "",
)
)
@@ -196,7 +208,7 @@ def parse_videos(data):
length = None
try:
- length = parse_duration_string(extract_text(eval_xpath(item, ".//span[contains(@class, 'time')]")))
+ length = parse_duration_string(extract_text(eval_xpath(item, ".//span[contains(@class, 'time')]")) or "")
except (ValueError, TypeError):
pass