#第一种# date: 特定的时间点触发# 2019-01-01 00:00:00 准时执行# import time
# from apscheduler.schedulers.blocking import BlockingScheduler
#
# def my_job():
# print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())))
# sched = BlockingScheduler()
# ## 采用dete固定时间模式,在特定时间只执行一次
# sched.add_job(my_job, 'date', run_date='2019-01-01 00:00:00')
# sched.start()# #第二种# interval固定时间间隔触发# 每隔五秒执行一次# import time
# from apscheduler.schedulers.blocking import BlockingScheduler
#
# def my_job():
# print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())))
#
# schedulers = BlockingScheduler(timezone='Asia/Shanghai')
# schedulers.add_job(my_job, 'interval', minutes =0.5)
# schedulers.start()# 间隔调度,参数如下:# weeks (int) – 间隔几周# days (int) – 间隔几天# hours (int) – 间隔几小时# minutes (int) – 间隔几分钟# seconds (int) – 间隔多少秒# start_date (datetime|str) – 开始日期# end_date (datetime|str) – 结束日期# timezone (datetime.tzinfo|str) – 时区# # #第三种# cron# 定时调度(例如在每一天上午八点半或者12点半执行任务)# #
# import time
# from apscheduler.schedulers.blocking import BlockingScheduler
# def everyday_crawler_job():
# print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())))
#
#
# sched = BlockingScheduler()
#
# #每隔一天 执行抓包程序
# # sched.add_job(everyday_crawler_job, 'interval', days=1)days
#
# #每天早上八点半和十二点半各执行一次抓包程序
# sched.add_job(everyday_crawler_job, 'cron', hour='19, 20', minute='56')
#
# sched.start()#参数# (int|str) 表示参数既可以是int类型,也可以是str类型
# (datetime | str) 表示参数既可以是datetime类型,也可以是str类型
# year (int|str) – 4-digit year -(表示四位数的年份,如2008年)
# month (int|str) – month (1-12) -(表示取值范围为1-12月)
# day (int|str) – day of the (1-31) -(表示取值范围为1-31日)
# week (int|str) – ISO week (1-53) -(格里历2006年12月31日可以写成2006年-W52-7(扩展形式)或2006W527(紧凑形式))
# day_of_week (int|str) – number or name of weekday (0-6 or mon,tue,wed,thu,fri,sat,sun) - (表示一周中的第几天,既可以用0-6表示也可以用其英语缩写表示)
# hour (int|str) – hour (0-23) - (表示取值范围为0-23时)
# minute (int|str) – minute (0-59) - (表示取值范围为0-59分)
# second (int|str) – second (0-59) - (表示取值范围为0-59秒)
# start_date (datetime|str) – earliest possible date/time to trigger on (inclusive) - (表示开始时间)
# end_date (datetime|str) – latest possible date/time to trigger on (inclusive) - (表示结束时间)
# timezone (datetime.tzinfo|str) – time zone to use for the date/time calculations (defaults to scheduler timezone) -(表示时区取值)