赞
踩
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"
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。