import requests
import base64
import hashlib
# 图片base64码
with open("F:\\a.png","rb") as f:
base64_data = base64.b64encode(f.read())
# base64.b64decode(base64data)
print(base64_data)
# 图片的md5值
file = open("F:\\a.png", "rb")
md = hashlib.md5()
md.update(file.read())
res1 = md.hexdigest()
print(res1)
# 企业微信机器人发送消息
url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=37b4b749-f8dc-4ddb-a585-1e4d6ebf15aaaaaa"
headers = {"Content-Type": "text/plain"}
data = {
"msgtype": "image",
"image": {
"base64": base64_data,
"md5": res1
}
}
r = requests.post(url, headers=headers, json=data)
print(r.text)
利用python和企业微信机器人发送图片
最新推荐文章于 2024-04-17 21:31:09 发布