简易实现自动签到并发送通知邮件

环境准备

Windows操作系统+adbshell1.0.40+pyhon3.7+visual stdio code stable+android手机+数据线,并配置环境变量

打卡程序

需要定位屏幕坐标

python 复制代码
import os
import time

a0=os.popen("adb shell input keyevent 26")
##b=a0.read()
##print(b)
time.sleep(5)     ##等待5秒
a1=os.popen("adb shell input swipe 767 1500 767 500")
time.sleep(5)
a2=os.popen("adb shell input tap 632 1605")
time.sleep(5)
a3=os.popen("adb shell input tap 330 610")
time.sleep(5)
a4=os.popen("adb shell input text xxxx")     ##DD密码
time.sleep(5)
a5=os.popen("adb shell input tap 945 752")
time.sleep(5)
a6=os.popen("adb shell input tap 783 1980")
time.sleep(5)
a7=os.popen("adb shell input tap 100 1017")
time.sleep(5)
a8=os.popen("adb shell input tap 770 630")
time.sleep(5)
a9=os.popen("adb shell input tap 801 1408")
time.sleep(5)
a10=os.popen("adb shell screencap -p /sdcard/1.png")   ##截图
time.sleep(5)

## ****3.发送邮件程序****
import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
import time

my_date=time.strftime('%m-%d',time.localtime(time.time()))         ##格式化本地日期、时分秒
my_time=time.strftime('%H:%M:%S',time.localtime(time.time()))
my_timestamp=my_date+' '+my_time

my_sender='xxxxx'    ##发送账号
my_pass = 'xxxxxx'          ##邮箱密码    
my_user='xxxx'     ##接收账号
def mail():                              ##定义邮件函数,结果初始为成功,若try下面有一个执行失败,就返回失败结果
    result=True
    try:
        
        ##msg=MIMEText(my_content,'html','utf-8')      ##html格式邮件,测试时用了一下
        ##msg=MIMEMultipart('related')                 ##带附件邮件,测试时用了一下
        msg=MIMEMultipart()                 ##多个附件模式
        msg['From']=formataddr(["xxx",my_sender])      ##发送人代称及账户
        msg['To']=formataddr(["xxx",my_user])     ##发送人代称及账户
        msg['Subject']="dingdingdaka"    ##标题

        ##msgAlternative = MIMEMultipart('alternative')
        ##msg.attach(msgAlternative)
        msg.attach(MIMEText(my_timestamp, 'plain', 'utf-8'))    ##正文,写时间

        my_att1=MIMEText(open('1.png', 'rb').read(), 'base64', 'utf-8')         ##通过open函数打开截图并读取,若没有截图会正常关闭
        my_att1["Content-Type"] = 'application/octet-stream'      ##流模式
        my_att1["Content-Disposition"] = 'attachment; filename="1.png"'     ##附件名称

        msg.attach(my_att1)

 
        server=smtplib.SMTP_SSL("smtp.qq.com", 465)     ##smtp服务器
        server.login(my_sender, my_pass)
        server.sendmail(my_sender,[my_user,],msg.as_string())
        server.quit()
    except Exception: 
        result=False
    return result
    
my_result=mail()
if my_result:
    print("success")
else:
    print("fail")

定时任务

在任务计划程序添加任务,python xxx.py

相关推荐
冷雨夜中漫步2 小时前
Python快速入门(6)——for/if/while语句
开发语言·经验分享·笔记·python
郝学胜-神的一滴3 小时前
深入解析Python字典的继承关系:从abc模块看设计之美
网络·数据结构·python·程序人生
百锦再3 小时前
Reactive编程入门:Project Reactor 深度指南
前端·javascript·python·react.js·django·前端框架·reactjs
喵手5 小时前
Python爬虫实战:旅游数据采集实战 - 携程&去哪儿酒店机票价格监控完整方案(附CSV导出 + SQLite持久化存储)!
爬虫·python·爬虫实战·零基础python爬虫教学·采集结果csv导出·旅游数据采集·携程/去哪儿酒店机票价格监控
2501_944934735 小时前
高职大数据技术专业,CDA和Python认证优先考哪个?
大数据·开发语言·python
helloworldandy5 小时前
使用Pandas进行数据分析:从数据清洗到可视化
jvm·数据库·python
肖永威6 小时前
macOS环境安装/卸载python实践笔记
笔记·python·macos
TechWJ6 小时前
PyPTO编程范式深度解读:让NPU开发像写Python一样简单
开发语言·python·cann·pypto
枷锁—sha7 小时前
【SRC】SQL注入WAF 绕过应对策略(二)
网络·数据库·python·sql·安全·网络安全
abluckyboy7 小时前
Java 实现求 n 的 n^n 次方的最后一位数字
java·python·算法