日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python飞书到期提醒

發布時間:2024/3/26 python 70 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python飞书到期提醒 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

本地檢測Excel文件中域名到期時間,發送飛書通知

#!/usr/bin/python3 #coding=utf-8 import json import requests import time import datetime import sys import csv #import importlib import re import collections as col #導入的庫 from openpyxl import load_workbook#importlib.reload(sys) #打開的文件class DateEncoder(json.JSONEncoder):def default(self, obj):if isinstance(obj, datetime.datetime):return obj.strftime('%Y-%m-%d %H:%M:%S')elif isinstance(obj, datetime.date):return obj.strftime("%Y-%m-%d")else:return json.JSONEncoder.default(self, obj)def send_card():"""發送普通消息"""aa = {"域名": a ,"平臺": p ,"到期時間": d.strftime("%Y-%m-%d")} #print(json.dumps(aa, cls=DateEncoder))#機器人地址,注意修改idurl = 'https://open.feishu.cn/open-apis/bot/v2/hook/<id>'headers = {"Content-Type": "text/plain"}true = Truedata = {"msg_type": "interactive","card": {"config": {"wide_screen_mode": true,"enable_forward": true},"elements": [{"tag": "div","text": {"content": json.dumps(aa, cls=DateEncoder).encode('utf-8').decode('unicode_escape') ,"tag": "lark_md"} },# {"tag": "div",# "text":{"content": "平臺: p" ,"tag": "lark_md"} },# {"tag": "div",# "text":{"content": d ,"tag": "lark_md"} },],"header": {"title": {"content": "域名即將到期提醒","tag": "plain_text"}}}}r = requests.post(url, headers=headers, json=data)return r.textif __name__ == '__main__':aheaders = {'Content-Type': 'application/json'}day_str = datetime.datetime.strptime(datetime.datetime.now().strftime("%Y-%m-%d"), "%Y-%m-%d") #print(day_str)#n_time=datetime.datetime.now() # 獲取當前時間 #n_time.strftime('%Y-%m-%d')fp = '/home/ftp/bao/domain1.xlsx'ws = load_workbook(fp) #要讀取的工作薄sheet = ws.get_sheet_by_name("Sheet1") #按行讀取for i in sheet.rows:a = i[0].value if i[0].value != None else '' #如果單元格的值為空,則空串d = i[1].value if i[1].value != None else ''p = i[2].value if i[2].value != None else ''e = d - day_strif (d - day_str).days <= 30: #構造cypher語句,用于在cypher-shell下執行#print ('match (n :Source) where n.name = ','"'+ a + '" set n += ', '{ synonym: "'+b + '" , ref: "'+c+'"};')# wm = wechat_monitor() # curl -X POST \ # "https://open.feishu.cn/open-apis/bot/v2/hook/f17c9e97-2d79-4f43-b6df-b0b70cdeb68d" \ # -H 'Content-Type: application/json' \ # -d '{ # "msg_type": "interactive", # "card":{ # "config": # {"wide_screen_mode": true,"enable_forward": true}, # "elements": # [{"tag": "div","text": {"content": a ,"tag": "lark_md"}}], # "header": {"title": {"content": e,"tag": "plain_text"} # } # # } # # }'#asendmessage()#true = True#infoxx()send_card()print (a,d,p)else:print (a,d,p)#class wechat_monitor(): # sendMessageUrl2 = "https://open.feishu.cn/open-apis/bot/v2/hook/f17c9e97-2d79-4f43-b6df-b0b70cdeb68d" #def sendmessage(data): # res2 = requests.post(sendMessageUrl2,headers=aheaders, data = json.dumps(data) )# return res2 #if __name__ == '__main__': # wm = wechat_monitor() # true = True # data = {"host":sys.argv[1],"title": sys.argv[2],"content": sys.argv[3],"time": sys.argv[4]} #def infoxx(): # data = { # "msg_type": "interactive", # "card": # {"config": # {"wide_screen_mode": true,"enable_forward": true}, # "elements": # [{"tag": "div","text": {"content": a ,"tag": "lark_md"}}], # "header": {"title": {"content": e,"tag": "plain_text"}} # } # }# res2 = wm.sendmessage(data)

總結

以上是生活随笔為你收集整理的python飞书到期提醒的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。