当前位置:   article > 正文

Python3将文件发送到企业微信_企业微信机器人 python 发送文件

企业微信机器人 python 发送文件

1、通过企业微信机器人,实现python3脚本将文本内容、文件、图片发送到企业微信群。
2、请在企业微信群创建机器人,并更改keyID变量
3、图片路径、文件路径的参数请记得更改

#! /usr/bin/python3
# -*- coding: utf-8 -*-

import csv
import hashlib
import json
import requests
import random
from bs4 import BeautifulSoup
import base64

def get_agent():
    # 客户端身份认证
    useragent1 = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"
    useragent2 = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"
    useragent3 = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.57"
    useragent4 = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"
    useragent5 = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.82 Safari/537.36"
    useragent6 = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/110.0"
    useragent7 = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36 Edg/101.0.1210.39"
    ulist = [useragent1, useragent2, useragent3, useragent4, useragent5, useragent6, useragent7]
    useragent = random.choice(ulist)
    return useragent

def get_data(fp):
    useragent = get_agent()
    url = "https://www.maigoo.com/top/430483.html"
    headers = {
   
        "User-Agent": useragent,
        "Host": "www.maigoo.com"
    
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号