實現手段:
1、對屏幕定時截圖
2、將截圖的圖片通過郵件發送到郵箱
依賴庫:pillow,time,yagmail
基礎知識:1:發送郵件
2:截圖:
3、定時
time.sleep(時間),默認為秒。
完整實現代碼:
import yagmail
from PIL import ImageGrab
import time
username = "xxxx@qq.com"#發送郵箱
password = "xxxx"
#設定發送的賬戶,方式
yag = yagmail.SMTP(user=username, password=password, host='smtp.qq.com')
#循環,也可以用while True來代替。
for i in range(5):
im = ImageGrab.grab() # 無參數默認全屏截屏
im.save('shot.jpg') # 截圖保存,默認是當前目錄
address = "xxxxx@qq.com"#發送到xxx郵箱
# 標題
title = [
"測試郵件" + str(i+1)
]
# 內容
content = [
"屏幕現況"
, yagmail.inline("shot.jpg") # 插入圖片並顯示到正文
]
# 4、發送郵件
yag.send(to=address, subject=title, contents=content)
# 5、關閉連接
yag.close()
time.sleep(10)#根據需求設定時間
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _(手動分割線)
博客小白,個人記錄,很多待補充,想到再慢慢修改,歡迎批評指正。
摘自:網絡上很多的大神。侵刪。。
轉載請附原文鏈接以及作者,謝謝。
一個啥都想整小白白白。。。