Skip to content

Commit 097a345

Browse files
committed
1.1
1 parent c11fa85 commit 097a345

File tree

6 files changed

+103
-30
lines changed

6 files changed

+103
-30
lines changed

.gitignore

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
config.py
2-
.idea/
3-
captcha/
4-
mentor/
5-
crack/
6-
homepage/htmls
7-
homepage/*.xlsx
8-
gui_get_captcha/
1+
/config.py
2+
/.idea/
3+
/captcha/
4+
/mentor/
5+
/crack/
6+
/homepage/htmls
7+
/homepage/*.xlsx
8+
/gui_get_captcha/
9+
/.vscode/
10+

mail.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from email.mime.text import MIMEText
77
from email.utils import formataddr
88

9-
from config import host, mail_username as username, mail_password as password, send_tos
9+
from config import host, mail_username as username, mail_password as password
1010

1111

1212
def loginToServer(host, user, password):
@@ -48,4 +48,4 @@ def send_mail(send_tos, name, subject, text, att_urls=None):
4848

4949
if __name__ == "__main__":
5050
# att_urls = ["************"]
51-
send_mail(send_tos=send_tos, name="SSSimon Yang", subject="***********", text="***********")
51+
send_mail(send_tos=["********@***.com"], name="SSSimon Yang", subject="***********", text="***********")

main/chrome.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
@file: chrome.py
77
@time: 2019/4/14 23:10
8-
@desc: pip install baidu-aip
8+
@desc:
99
"""
1010
from selenium import webdriver
1111

main/login.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
@file: login.py
77
@time: 2019/8/24 21:30
88
@desc: pip install baidu-aip
9+
利用baidu api进行验证码识别
910
"""
1011

1112
import json
@@ -20,7 +21,7 @@
2021

2122
def image_to_string(path):
2223
from aip import AipOcr
23-
APP_ID = config.API_ID # 填你自己的ID
24+
APP_ID = config.APP_ID # 填你自己的ID
2425
API_KEY = config.API_KEY # 填你自己的APIKEY
2526
SECRET_KEY = config.SECRET_KEY # 填你自己的SECRETKEY
2627
client = AipOcr(APP_ID, API_KEY, SECRET_KEY)

personal_page/evaluation.py

+20-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
@file: evaluation.py
77
@time: 2019/9/9 20:39
8-
@desc:
8+
@desc: you may run across connect error, if such error occurs, just rerun the code
99
"""
1010
import csv
1111
import re
@@ -17,6 +17,7 @@
1717
from lxml import etree
1818
from urllib3 import HTTPSConnectionPool
1919

20+
import config
2021
from mail import send_mail
2122
from main.login import login
2223

@@ -88,7 +89,13 @@ def single_access(s, url):
8889
return False
8990

9091

91-
def main(csv_file=r'************.csv'):
92+
def main(csv_file):
93+
"""
94+
process csv to run many ids in line
95+
you can change some code to use your own file
96+
:param csv_file: csv filepath
97+
:return:
98+
"""
9299
with open(csv_file, encoding='utf-8') as f:
93100
csv_reader = csv.reader(f)
94101
rows = list(csv_reader)[6:]
@@ -104,7 +111,14 @@ def main(csv_file=r'************.csv'):
104111
print("/n".join(results))
105112

106113

107-
def process(user_id, user_password, email):
114+
def process(user_id, user_password, email=''):
115+
"""
116+
do a single evaluation task
117+
:param user_id: your user_id like '201*****48'
118+
:param user_password: your user_password I don't recommend user space in password
119+
:param email: email address to send the info of your task
120+
:return:
121+
"""
108122
try:
109123
s = login(user_id, user_password)
110124
except HTTPSConnectionPool:
@@ -123,6 +137,6 @@ def process(user_id, user_password, email):
123137

124138

125139
if __name__ == '__main__':
126-
pass
127-
# main()
128-
# process('xxxxxxx', 'xxxxxxxx', '[email protected]')
140+
# main(r'************.csv')
141+
process(config.user_id, config.user_password)
142+
# process(config.user_id, config.user_password, config.user_email)

readme.md

+68-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,68 @@
1-
所有代码主要针对对象为西南交通大学教务网或扬华网
2-
3-
/homepage/jiaowu.py 教务网主页信息爬取
4-
/homepage/yanghua.py 扬华网信息爬取
5-
/main/chrome.py chrome模拟登录教务网
6-
/main/login.py 利用百度api识别验证码登录教务网
7-
/personal_page/evaluation.py 教务登陆后主页完成课程评价
8-
/personal_page/tuimian.py 教务登陆后完成保研课查询
9-
mail.py 辅助完成邮件发送
10-
11-
install
12-
baidu-aip hyper lxml openpyxl Pillow psycopg2 requests selenium xlrd
1+
## swjtudean
2+
3+
> 所有代码主要爬虫对象为西南交通大学教务网或扬华网
4+
5+
- /homepage/jiaowu.py 教务网主页信息爬取
6+
- /homepage/yanghua.py 扬华网信息爬取
7+
- /main/chrome.py chrome模拟登录教务网
8+
- /main/login.py 利用百度api识别验证码登录教务网
9+
- /personal_page/evaluation.py 教务登陆后个人主页完成课程评价
10+
- /personal_page/tuimian.py 教务登陆后个人主页完成保研课查询
11+
- /mail.py 辅助完成邮件发送
12+
13+
涉及到的库
14+
baidu-aip lxml openpyxl Pillow psycopg2 requests selenium xlrd
15+
16+
> python版本 最低为3.6
17+
18+
安装包
19+
`pip install baidu-aip lxml openpyxl Pillow requests xlrd`
20+
> 除baidu-aip之外的所有包都可用conda安装
21+
22+
### 自动评价
23+
自动评价涉及的文件为
24+
- /main/login.py
25+
- /personal_page/evaluation.py
26+
27+
进入[百度ai开放平台](http://ai.baidu.com/)
28+
点击控制台 登录 选择左侧文字识别 然后创建应用
29+
应用的名字和简介随便写,常见成功后会显示`AppID API Key Secret Key`
30+
在该目录下创建`config.py`
31+
32+
-----------
33+
config.py
34+
```
35+
APP_ID = '17868961' # 对应替换为你申请的AppID
36+
API_KEY = 'sZGw4ynaOLIdXoijfI5IFbYX' # 对应替换为你申请的API Key
37+
SECRET_KEY = '98q8NEoKTWioZzv8Bey7HOEYgiYTDL8I' # 对应替换为你申请的Secret Key
38+
user_id = '201*****' # 对应写入你自己的教务账号
39+
user_password = '*****' # 对应写入你自己的教务密码
40+
```
41+
> 如果不想申请可以直接用我给的,但是一个接口每天使用次数有限制,建议自己申请并进行替换
42+
43+
该目录下运行
44+
`
45+
python personal_page/evaluation.py
46+
`
47+
48+
#### 启动`mail.py`的功能
49+
`config.py`加入如下信息
50+
```
51+
mail_username = '****************' # email地址
52+
mail_password = '****************' # email开启smtp服务后提供的登录授权码
53+
host = 'smtp.***.com' # 对应的smtp服务器
54+
user_email = '****************' # 通知到的email地址
55+
```
56+
然后更改evaluation.py的最后部分
57+
```
58+
if __name__ == '__main__':
59+
# main(r'************.csv')
60+
# process(config.user_id, config.user_password)
61+
process(config.user_id, config.user_password, config.user_email)
62+
```
63+
同样,执行
64+
`
65+
python personal_page/evaluation.py
66+
`
67+
68+
Wish you a good day!

0 commit comments

Comments
 (0)