直接上代码
# -*-coding:utf-8-*-
# 刘文豪
# 大帅哥
import requests
import time
def postmessage():
url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4dd11710-f4a8-47b2-8ab4-09f88ede93ca"
headers = {"Content-Type": "text/plain"}
s = "你睡了吗? "
data = {
"msgtype": "text",
"text": {
"content": s,
}
}
r = requests.post(url, headers=headers, json=data)
print(r.text)
while(True):
postmessage()
time.sleep(20)

本文介绍如何使用Python编写代码,通过企业微信 webhook 实现定时发送消息的功能,并实现一个无限循环监控机制。核心内容涉及HTTP请求库requests和微信企业号API的调用。
1819

被折叠的 条评论
为什么被折叠?



