import requests import json # Webhook URL url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=553f02de-0ef4-49ce-8d68-2489c032d42f' def send_message(componment, farmId, text): # 设置请求头 headers = {'Content-Type': 'application/json'} # 设置消息内容 data = { "msgtype": "markdown", "markdown": { "content": f"""告警 >组件:{componment} >场站:{farmId} >类型:{text}""" } } # 发送POST请求 response = requests.post(url, headers=headers, data=json.dumps(data)) # 输出响应内容 print(response.text)