123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- # -*- coding: utf-8 -*-
- # @Author: wangkun
- # @Time: 2023/4/19
- import time
- from datetime import date, timedelta
- # import ast
- # task_str = "[('task_id','11')," \
- # "('task_name','小年糕小时榜')," \
- # "('source','xiaoniangao')," \
- # "('start_time','1681834560000')," \
- # "('interval','1'),('mode','hour')," \
- # "('rule','[{'duration':{'min':40,'max':0}},{'playCnt':{'min':4000,'max':0}},{'period':{'min':10,'max':0}},{'fans':{'min':0,'max':0}},{'videos':{'min':0,'max':0}},{'like':{'min':0,'max':0}},{'videoWidth':{'min':0,'max':0}},{'videoHeight':{'min':0,'max':0}}]')," \
- # "('spider_name','')," \
- # "('machine','')," \
- # "('status','0')," \
- # "('create_time','1681889875288')," \
- # "('update_time','1681889904908')," \
- # "('operator','王坤')]"
- # task_str = task_str.replace("'[{", '[{').replace("}}]'", '}}]')
- # print(task_str)
- # task_list = eval(task_str)
- # print(task_list)
- # print(type(task_list))
- # task_dict = dict(task_list)
- # print(task_dict)
- # print(type(task_dict))
- #
- #
- # rule = task_dict['rule']
- # print(type(rule))
- # print(rule)
- # print(task_dict)
- # task_dict['rule'] = dict()
- # for item in rule:
- # for k, val in item.items():
- # task_dict['rule'][k] = val
- # print('\n')
- # print(task_dict['rule'])
- # print('\n')
- # print(task_dict)
- # str1 = task_str.split(",('rule',")[0]+"]"
- # print(type(str1))
- # print(str1)
- # eval1 = eval(str1)
- # print(type(eval1), eval1)
- # dict1 = dict(eval1)
- # print(type(dict1), dict1)
- # print("============\n")
- #
- # "[{'duration':{'min':40,'max':0}},{'playCnt':{'min':4000,'max':0}},{'period':{'min':10,'max':0}},{'fans':{'min':0,'max':0}},{'videos':{'min':0,'max':0}},{'like':{'min':0,'max':0}},{'videoWidth':{'min':0,'max':0}},{'videoHeight':{'min':0,'max':0}}]"
- # print(task_str.split(",('rule',")[-1].split(",('spider_name'")[0].replace(")", ""))
- # # rule_str = task_str.split(",('rule',")[-1].split(",('spider_name'")[0].replace(")", "").replace("'[{", '[{').replace("}}]'", '}}]')
- # rule_str = task_str.split(",('rule',")[-1].split(",('spider_name'")[0].replace(")", "")[1:-1]
- # print(type(rule_str))
- # print(rule_str)
- #
- #
- # rule_list = eval(rule_str)
- # print(type(rule_list))
- # print(rule_list)
- # rule_dict = {'duration': {'min': 40, 'max': 0}, 'playCnt': {'min': 4000, 'max': 0}, 'period': {'min': 10, 'max': 0}, 'fans': {'min': 0, 'max': 0}, 'videos': {'min': 0, 'max': 0}, 'like': {'min': 0, 'max': 0}, 'videoWidth': {'min': 0, 'max': 0}, 'videoHeight': {'min': 0, 'max': 0}}
- # rule_dict = {}
- #
- # for k, v in rule_dict.items():
- # print(f"{k}:{v}")
- #
- # rule_duration_min = rule_dict.get('duration', {}).get('min', 0)
- # rule_duration_max = rule_dict.get('duration', {}).get('max', 100000000)
- # rule_playCnt_min = rule_dict.get('playCnt', {}).get('min', 0)
- # rule_playCnt_max = rule_dict.get('playCnt', {}).get('max', 100000000)
- # rule_period_min = rule_dict.get('period', {}).get('min', 0)
- # rule_period_max = rule_dict.get('period', {}).get('max', 100000000)
- # rule_fans_min = rule_dict.get('fans', {}).get('min', 0)
- # rule_fans_max = rule_dict.get('fans', {}).get('max', 100000000)
- # rule_videos_min = rule_dict.get('videos', {}).get('min', 0)
- # rule_videos_max = rule_dict.get('videos', {}).get('max', 100000000)
- # rule_like_min = rule_dict.get('like', {}).get('min', 0)
- # rule_like_max = rule_dict.get('like', {}).get('max', 100000000)
- # rule_videoWidth_min = rule_dict.get('videoWidth', {}).get('min', 0)
- # rule_videoWidth_max = rule_dict.get('videoWidth', {}).get('max', 100000000)
- # rule_videoHeight_min = rule_dict.get('videoWidth', {}).get('min', 0)
- # rule_videoHeight_max = rule_dict.get('videoWidth', {}).get('max', 100000000)
- #
- # print(f"rule_duration_min:{rule_duration_min}")
- # print(f"rule_duration_max:{rule_duration_max}")
- # print(f"rule_playCnt_min:{rule_playCnt_min}")
- # print(f"rule_playCnt_max:{rule_playCnt_max}")
- # print(f"rule_period_min:{rule_period_min}")
- # print(f"rule_period_max:{rule_period_max}")
- # print(f"rule_fans_min:{rule_fans_min}")
- # print(f"rule_fans_max:{rule_fans_max}")
- # print(f"rule_videos_min:{rule_videos_min}")
- # print(f"rule_videos_max:{rule_videos_max}")
- # print(f"rule_videoWidth_min:{rule_videoWidth_min}")
- # print(f"rule_videoWidth_max:{rule_videoWidth_max}")
- # print(f"rule_videoHeight_min:{rule_videoHeight_min}")
- # print(f"rule_videoHeight_max:{rule_videoHeight_max}")
- time_str = (date.today() + timedelta(days=-10)).strftime("%Y-%m-%d %H:%M:%S")
- time_stamp = int(time.mktime(time.strptime(time_str, "%Y-%m-%d %H:%M:%S")))
- print(time_str)
- print(time_stamp)
|