fix: 帖子时间解析过滤2053等异常年份,使用crawled_at兜底
This commit is contained in:
parent
c20a2f50ce
commit
be0bc603b7
|
|
@ -179,7 +179,14 @@ class YichensTodaySpider(PaginationSpider):
|
||||||
created_at = None
|
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)
|
m = re.search(r"(\d{4}/\d{1,2}/\d{1,2}\s+\d{1,2}:\d{2}:\d{2})", page_text)
|
||||||
if m:
|
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)
|
phones = re.findall(r'1[3-9]\d{9,10}', page_text)
|
||||||
contact = ",".join(dict.fromkeys(phones[:5])) if phones else None
|
contact = ",".join(dict.fromkeys(phones[:5])) if phones else None
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue