一次失败的尝试

为了及时知道实验是否可选,于是写了个脚本,但是设计有点失败:

  1. js始终有使那个判断的条件成立。
  2. 没有成功挂到云主机上

update:

在云主机配好了之后,centos进行如下的设置

1
setsid python xxx.py

表示时刻运行

若想查看所有后台运行的进程

1
#ps -aux

这里可以看到每个进程都有一个PID,如果想杀死这个进程,则使用

1
#kill-9[PID]-9表示强迫进程立即停止
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Copyright (C) 2019 by the XiDian Open Source Community.
#
# This file is part of xidian-scripts.
#
# xidian-scripts is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# xidian-scripts is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
# for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with xidian-scripts. If not, see <http://www.gnu.org/licenses/>.
# -*- coding: utf-8 -*-
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) #登录SMTP服务器
s.sendmail(msg_from, msg_to, msg.as_string())#发邮件 as_string()把MIMEText对象变成str
print ("发送成功")
except s.SMTPException:
print ("发送失败")
finally:
s.quit()

未解决的问题

文章目录
  1. 1. 未解决的问题
{{ live2d() }}