说明:
1、通过htmltable生成html表格,并且调整表格字体、边框、颜色等。
2、将网站链接写入html表格中,只要点击查看详情即可跳转到对应网站访问。
3、发送文件和消息到企业微信群。
#! /usr/bin/python3
# -*- coding: utf-8 -*-
from HTMLTable import HTMLTable
import requests
import time
import imgkit
# 发送消息
def send_message(key,text):
api_url = f"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={key}"
headers = {
"Content-Type": "application/json;charset=utf-8"
}
data = {
"msgtype": "text",
"text": {
"content": text,
"mentioned_list": ["@all"],
# "mentioned_mobile_list": ["@all"]
}
}
req = requests.post(url=api_url,json=data, headers=headers)
return req
# 发送文件
def send_file(key, file_path):
data = {
'file': open(file_path, 'rb')
}
url = f"https://qyapi.weixin.qq.com/cgi-bin/webhook/upload_media?key={key}&type=file"
req = requests.post(url, files=data)
if req.status_code == 200:
json_req = req.json()
media_