fix: 帖子时间解析过滤2053等异常年份,使用crawled_at兜底

This commit is contained in:
caibotmini 2026-04-09 23:22:23 +08:00
parent c20a2f50ce
commit be0bc603b7
1 changed files with 8 additions and 1 deletions

View File

@ -179,7 +179,14 @@ class YichensTodaySpider(PaginationSpider):
created_at = None
m = re.search(r"(\d{4}/\d{1,2}/\d{1,2}\s+\d{1,2}:\d{2}:\d{2})", page_text)
if m:
created_at = m.group(1).replace("/", "-")
date_str = m.group(1).replace("/", "-")
try:
from datetime import datetime
dt = datetime.strptime(date_str, "%Y-%m-%d %H:%M:%S")
if 2020 <= dt.year <= 2030:
created_at = date_str
except:
pass
phones = re.findall(r'1[3-9]\d{9,10}', page_text)
contact = ",".join(dict.fromkeys(phones[:5])) if phones else None