htmltabl生成html表格并发送企业微信

本文介绍如何利用Python的htmltable库创建HTML表格,定制样式如字体、边框和颜色,并将含有网站链接的表格内容,通过自动化方式发送到企业微信群,实现运维监控信息的高效传递。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

说明:

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()
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

秋天枫叶35

希望能帮到你,谢谢你能阅读~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值