許多大學會用 Zuvio IRS 來線上點名,而線上點名有一個好處,只要不是開 GPS 點名,我可以在任何有網路的地方做點名的動作,但仍有一個缺點,我們不知道老師什麼時候會開啟簽到,需要有上課的同學提醒,這樣要翹早八的課會睡得很不安穩捏!在同學的提議下我嘗試開發自動 Zuvio 點名程式,沒想到還真成功了,雖然粗糙,但確實可以用!
本程式使用瀏覽器模擬與原始碼解析技術,非常的 “Hard code”,若 Zuvio 系統變更網頁原始碼將會無法使用,需修改原始碼。
準備工作
安裝 Chrome 瀏覽器 (重要!!!)
安裝 Python
安裝相依性套件
相依性資料
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[[ source ]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[ dev-packages ]
autopep8 = "*"
[ packages ]
selenium = "*"
requests = "*"
beautifulsoup4 = "*"
pyinstaller = "*"
[ requires ]
python_version = "3.7"
config.py
在裡面修改要自動點名的課程"點名網址"、帳號及密碼。
1
2
3
4
5
6
7
8
9
10
11
Myconfig = {
#例 "URL":"https://irs.zuvio.com.tw/student5/irs/rollcall/506869",
"URL" : "zuvio點名網址" ,
"user" : "zuvio帳號" ,
"password" : "zuvio密碼" ,
##Do no edit below if you are not developer.
"music" : "alarm.mp3" ,
"driver" : r "binary\chromedriver.exe" ,
"gui" : False
}
App.py
主程式
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
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.remote.remote_connection import LOGGER
import requests
import logging
import time
from bs4 import BeautifulSoup
import random
from config import Myconfig
# 設定Logging
logging . basicConfig ( level = logging . INFO ,
format = ' %(asctime)s %(levelname)s %(message)s ' ,
datefmt = '%H:%M:%S' )
def run ():
chrome_options = Options ()
if ( not ( Myconfig [ "gui" ])):
chrome_options . add_argument ( '--headless' )
LOGGER . setLevel ( logging . WARNING ) #設定selenium 紀錄層級,預設warning
driver = webdriver . Chrome ( Myconfig [ "driver" ], options = chrome_options )
#Login
logging . info ( "進入登入頁" )
driver . get ( "https://irs.zuvio.com.tw/" )
driver . find_element ( By . ID , "email" ) . send_keys ( Myconfig [ "user" ])
driver . find_element ( By . ID , "password" ) . send_keys ( Myconfig [ "password" ])
driver . find_element ( By . ID , "login_btn" ) . submit ()
#time.sleep(3)
driver . get ( Myconfig [ "URL" ])
logging . info ( "登入成功" )
#解析原始碼
#time.sleep(1)
logging . info ( "準備開始循環" )
while True :
PageSource = driver . page_source
soup = BeautifulSoup ( PageSource , 'html.parser' )
result = soup . find ( "div" , class_ = "irs-rollcall" )
logging . debug ( result )
if ( "準時" in str ( result )):
return True
if ( "簽到開放中" in str ( result )):
logging . info ( "點名中" )
driver . find_element ( By . ID , "submit-make-rollcall" ) . click ()
else :
logging . info ( "無點名資訊" )
driver . refresh ()
time . sleep ( random . randint ( 3 , 7 ))
if __name__ == "__main__" :
run ()
logging . info ( "選課循環階段結束" )
執行python app.py
後程式會去讀取config.py
內的資訊,並開啟自動化的 Chrome 瀏覽器,每 3-7 秒隨機重新整理點名頁面,若發現有點名便自動點擊!
經過測試確實可以一覺醒來點名就準時,超實用的啦~~
參考照片
文章作者
oxygen
上次更新
2020-05-09
授權條款
Copyright © 2017-2024 oxygen. All rights reserved.