hub-gif f915653104 feat(dataset): 库内浏览支持跳转页、排序与类目价格筛选
新增 JdLeafCategoryNorm 与 price 解析字段;数据集 API 支持 sort/order、category_norm_id、price 区间与类目路径模糊;摘要返回类目选项;前端 JobDatasetModal 增加筛选与分页跳转。

Made-with: Cursor
2026-04-16 09:51:26 +08:00

30 lines
834 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""从爬虫导出单元格解析数值价格(供入库索引与数据集筛选)。"""
from __future__ import annotations
import re
def float_price_from_cell(s: str | None) -> float | None:
t = (s or "").strip().replace(",", "").replace("", "")
if not t:
return None
m = re.search(r"(\d+(?:\.\d+)?)", t)
if not m:
return None
try:
v = float(m.group(1))
except ValueError:
return None
if 0 < v < 1_000_000:
return v
return None
def effective_list_price_value(coupon: str, price: str, original: str) -> float | None:
"""优先券后价,其次标价,再次原价(与列表侧展示习惯一致)。"""
for s in (coupon, price, original):
v = float_price_from_cell(s)
if v is not None:
return v
return None