import auth.ids
import json
import credentials
import bs4
import requests
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.header import Header
import time
ses = auth.ids.get_login_session(
'https://b.xidian.edu.cn/student/main', credentials.IDS_USERNAME, credentials.IDS_PASSWORD)
ans = ses.get('https://b.xidian.edu.cn/student/select', headers={
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
}).text
pattern = r"没有检索到数据"
print(ans)
while(True):
ans = ses.get('https://b.xidian.edu.cn/student/select', headers={
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
}).text
has = True
idx = 0
print(11)
for i in ans:
if(i == pattern[idx]):
idx+=1
else:
idx = 0
if(idx == 7):
has = False
break
if(has):
break
time.sleep(10)
msg_from='tianbaolin1@qq.com'
passwd=''
msg_to='tianbaolin1@qq.com'
subject="python邮件测试"
content="这是我使用python smtplib及email模块发送的邮件"
msg=MIMEText(content)
msg['Subject'] = subject
msg['From'] = msg_from
msg['To'] = msg_to
try:
s = smtplib.SMTP_SSL("smtp.qq.com",465)
s.login(msg_from, passwd)
s.sendmail(msg_from, msg_to, msg.as_string())
print ("发送成功")
except s.SMTPException:
print ("发送失败")
finally:
s.quit()