Python3 钉钉群推送消息

项目需求,Python爬虫后,需要对对应的钉钉群发生监控消息,这里使用requst调用。

import requests

ding_access = "https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxxxxxxx"
jsonText = {
    "msgtype": "text",
    "text": {
        "content": "监控我就是我, 是不一样的烟火@156xxxx8827"
    },
    "at": {
        "atMobiles": [
            "156xxxx8827",
            "189xxxx8325"
        ],
    "isAtAll": "true"
    }
}

def dingtalk(data):
    requests.post(ding_access, json=data)

if __name__ == '__main__':
    dingtalk(jsonText)

非常简单,几行代码搞定,运行测试成功。

另,钉钉机器人官方文档,可参考 https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章