|
@@ -24,11 +24,11 @@ class Common:
|
|
|
# 统一获取当前时间 <class 'datetime.datetime'> 2022-04-14 20:13:51.244472
|
|
|
now = datetime.now()
|
|
|
# 昨天 <class 'str'> 2022-04-13
|
|
|
- yesterday = (date.today() + timedelta(days=-1)).strftime("%Y/%m/%d")
|
|
|
+ yesterday = (date.today() + timedelta(days=-1)).strftime("%Y-%m-%d")
|
|
|
# 今天 <class 'datetime.date'> 2022-04-14
|
|
|
today = date.today()
|
|
|
# 明天 <class 'str'> 2022-04-15
|
|
|
- tomorrow = (date.today() + timedelta(days=1)).strftime("%Y/%m/%d")
|
|
|
+ tomorrow = (date.today() + timedelta(days=1)).strftime("%Y-%m-%d")
|
|
|
|
|
|
# 使用 logger 模块生成日志
|
|
|
@staticmethod
|
|
@@ -46,7 +46,7 @@ class Common:
|
|
|
# log_name = time.strftime("%Y-%m-%d", time.localtime(time.time())) + f'-{crawler}-{log_type}.log'
|
|
|
# log_name = datetime.datetime.now().strftime('%Y-%m-%d') + f'-{crawler}-{log_type}.log'
|
|
|
# log_name = f"{date.today():%Y-%m-%d}-{crawler}-{log_type}.log"
|
|
|
- log_name = f"{crawler}-{log_type}-{date.today().strftime('%Y-%m-%d')}.log"
|
|
|
+ log_name = f"{crawler}-{log_type}-{datetime.now().date().strftime('%Y-%m-%d')}.log"
|
|
|
|
|
|
# 日志不打印到控制台
|
|
|
logger.remove(handler_id=None)
|
|
@@ -487,6 +487,6 @@ class Common:
|
|
|
if __name__ == "__main__":
|
|
|
# print(datetime.time(hour=0, minute=0))
|
|
|
# print(f'{date.today():%Y-%m-%d}')
|
|
|
- print(date.today().strftime('%Y-%m-%d'))
|
|
|
+ print(datetime.now().date().strftime('%Y-%m-%d'))
|
|
|
pass
|
|
|
|