企业微信机器人发送Markdown python脚本

自动判断脚本长度自动截取

def send_wx(txt):
    webhook = ''
    a = str.encode(txt)
    for i in range(int(len(a) / 4096) + 1):
        d = i * 4096
        f = (i + 1) * 4096
        if len(bytes.decode(a[d:f])):
            requests.post(url=webhook, headers=headers, 
                          json={"msgtype": "markdown", "markdown": {"content": (bytes.decode(a[d:f])).strip()}}).json()
def send_wx(txt, webhook):
    headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36'}
    txt = str(txt)
    a = str.encode(str.strip(txt))
    for i in range(int(len(a) / 4096) + 1):
        d = i * 4096
        f = (i + 1) * 4096
        if len(bytes.decode(a[d:f])):
            requests.post(url=webhook, headers=headers,
                          json={"msgtype": "markdown", "markdown": {"content": bytes.decode(a[d:f])}}).json()
posted @ 2020-10-23 16:56  运维之爪  阅读(1960)  评论(0编辑  收藏  举报