項目需求,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