钉钉报警的代码,可直接使用
钉钉发送Markdown格式:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# auther:liuguanglu
import json
import time
import os
try:
import requests
except:
os.system('pip3 install requests')
def sendmessage(message,):
try:
local_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
print(111,message)
print(type(json.loads(message)))
message=json.loads(message)
url = 'https://oapi.dingtalk.com/robot/send?access_token=66722e7336096ba8c69a1ef957b54e86dc47003d909ecdeb12a43bf40c6edcec' # 钉钉机器人的webhook地址
HEADERS = {
"Content-Type": "application/json ;charset=utf-8 "
}
String_textMsg = {
"msgtype": "markdown",
"markdown": {
"title": "#%s"%message['msg'],
"t