使用python向钉钉群聊发送消息
一、在钉钉群中新建机器人
在群设置中添加机器人


选择自定义
勾选对应的安全设置
完成后会展示webhook,将地址复制出来,并记录,后面会用到

二、使用代码发送消息
python
import requests
import time
timestamp = str(round(time.time() * 1000))
print(timestamp)
url='...' # 这里写前面记录的webhook地址
data = {
"msgtype": "text",
"text": {
"content": "测试机器人"
}
}
res = requests.post(url, json=data)
print(res.text)
运行后消息发送成功
