#coding:utf8 import sys import os sys.path.append(os.path.join(os.path.dirname(__file__),"..")) from utils.Utils import sendEmail,getCurrent_date import datetime import time from export.exportDocument import exportDocument_medicine,list_df_columns import pandas as pd from apscheduler.schedulers.blocking import BlockingScheduler def export_medicine_friday(): current_date = getCurrent_date("%Y-%m-%d") start_time = time.strftime("%Y-%m-%d",time.localtime(time.mktime(time.localtime())-6*24*60*60)) if current_date<="2022-04-25": if datetime.datetime.now().weekday()==4: df_data = exportDocument_medicine(start_time,current_date) df = pd.DataFrame(df_data) filename = os.path.dirname(__file__)+"/data/%s年%s至%s医疗数据导出.xlsx"%(start_time[:-4],start_time,current_date) df.to_excel(filename,columns=['公告标题', '公告类别', '省份', '城市', '发布时间', '项目编号', '招标单位', '招标联系人', '招标联系人电话', '代理单位', '代理联系人', '代理联系人电话', '比地招标公告地址', '中标单位', '中标金额', '招标金额', '中标单位联系人', '中标单位联系电话']) host = "smtp.exmail.qq.com" username = "vip@bidizhaobiao.com" password = "Biaoxun66-" receivers = ["1985262186@qq.com","1175730271@qq.com","1265797328@qq.com","1289358902@qq.com"] attachs = [filename] sendEmail(host,username,password,receivers,attachs=attachs) def job_medicine_friday(): _scheduler = BlockingScheduler() _scheduler.add_job(export_medicine_friday,"cron",day_of_week='fri',hour=18) _scheduler.start() if __name__=="__main__": job_medicine_friday()