12345678910111213141516171819202122 |
- 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"""<font color=\'warning\'>告警</font>
- >组件:<font color=\'comment\'>{componment}</font>
- >场站:<font color=\'comment\'>{farmId}</font>
- >类型:<font color=\'comment\'>{text}</font>"""
- }
- }
- # 发送POST请求
- response = requests.post(url, headers=headers, data=json.dumps(data))
- # 输出响应内容
- print(response.text)
|