import time
import urllib
import urllib.request
import requests
import os
import wget
# smtplib 用于邮件的发信动作
import smtplib
# email 用于构建邮件内容
from email.mime.text import MIMEText
# 构建邮件头
from email.header import Header
#windows微信下载地址
WinWechatSetupUrl = 'https://dldir1.qq.com/weixin/Windows/WeChatSetup.exe'
#获取下载文件名字
WinWeChatSetup_file_name = wget.filename_from_url(WinWechatSetupUrl)
#开始下载
WinWeChatSetup_file_name = wget.download(WinWechatSetupUrl)
#企业微信下载地址
WorkUrl = 'https://dldir1.qq.com/wework/work_weixin/WeCom_4.0.19.6020.exe'
Work_file_name = wget.filename_from_url(WorkUrl)
Work_file_name = wget.download(WorkUrl)
#飞书下载地址
FeiShuUrl = 'https://sf3-cn.feishucdn.com/obj/ee-appcenter/27dff55e/Feishu-win32_ia32-5.23.7-signed.exe'
FeiShu_file_name = wget.filename_from_url(FeiShuUrl)
FeiShu_file_name = wget.download(FeiShuUrl)
#阿里邮箱下载地址
ALiMailUrl = 'https://aliyun-alimail-desktop.oss-cn-hangzhou.aliyuncs.com/Windows/lastestpackage/Alimail.exe'
ALiMail_file_name = wget.filename_from_url(ALiMailUrl)
ALiMail_file_name = wget.download(ALiMailUrl)
#腾讯会议下载地址
MeeTingUrl = 'https://meeting.tencent.com/download-win.html?fromSource=sem81_gwzcw.447781123.4477849.447781162&bd_vid=11779616155031559878'
MeeTing_file_name = wget.filename_from_url(MeeTingUrl)
MeeTing_file_name = wget.download(MeeTingUrl)
#下面是发送邮件的配置,如果不需要可以不看。-------------------------------------
# 发信方的信息:发信邮箱,邮箱授权码
from_addr = '邮箱账号'
password = '邮箱密码'
# 收信方邮箱
to_addr = '收信方地址'
# 发信服务器
smtp_server = ''
# 邮箱正文内容,第一个参数为内容,第二个参数为格式(plain 为纯文本),第三个参数为编码
msg = MIMEText('软件下载完成:软件名:' + WinWeChatSetup_file_name + ' ' + Work_file_name + ' ' + FeiShu_file_name + ' ' + ALiMail_file_name + ' ' + MeeTing_file_name, 'plain', 'utf-8')
# 邮件头信息
msg['From'] = Header('软件包更新') # 发送者
msg['To'] = Header('北京IT') # 接收者
subject = '软件包更新报告'
msg['Subject'] = Header(subject, 'utf-8') # 邮件主题
try:
smtpobj = smtplib.SMTP_SSL(smtp_server)
# 建立连接--qq邮箱服务和端口号
smtpobj.connect(smtp_server, 465)
# 登录--发送者账号和口令
smtpobj.login(from_addr, password)
# 发送邮件
smtpobj.sendmail(from_addr, to_addr, msg.as_string())
print("邮件发送成功")
except smtplib.SMTPException:
print("无法发送邮件")
finally:
# 关闭服务器
smtpobj.quit()
脚本写完之后可以添加在Windows计时任务