
实验室安全考试刷题
进入实验室之前需要刷实验室安全的课程并通过考试,这儿有两个脚本可以自动化完成
刷时长脚本
需要安装selenium库:pip install selenium
修改user_name为学号,password为登录办事大厅的密码
随后执行脚本
脚本缺点,部分题目需要手动切换网页刷新
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
LOGIN_URL = "http://10.22.107.77"
user_name = "account" # account
password = "password" # password
driver = webdriver.Edge()
driver.get(LOGIN_URL)
login_btn = driver.find_element(By.XPATH, "/html/body/div/div/div/div[2]/div/div/div[2]/input")
login_btn.click()
time.sleep(3)
user_name_input = driver.find_element(By.XPATH, '//*[@id="username"]')
user_name_input.send_keys(user_name)
password_input = driver.find_element(By.XPATH, '//*[@id="password"]')
password_input.send_keys(password)
post_btn = driver.find_element(By.XPATH, '/html/body/div/div[2]/div[2]/div[2]/div[2]/div/div[3]/div/div[1]/form/p[4]/button')
post_btn.click()
time.sleep(3)
learn_gate_btn = driver.find_element(By.XPATH, '/html/body/div[1]/div[2]/ul/li[4]/a')
learn_gate_btn.click()
time.sleep(3)
all_url_ul = driver.find_element(By.XPATH, '/html/body/div[2]/div[2]/div[1]/ul')
all_url_href = all_url_ul.find_elements(By.TAG_NAME, "li")
all_url_list = []
for idx, item in enumerate(all_url_href):
a = item.find_element(By.TAG_NAME, "a")
href = a.get_attribute("href")
print(href)
all_url_list.append(href)
all_url_list.append('http://10.22.107.77/redir.php?catalog_id=132&object_id=2590') # sign
driver.find_element(By.XPATH, '/html/body/div[1]/div[2]/ul/li[5]/a').click()
all_a_in_td = driver.find_element(By.XPATH, '/html/body/div[2]/div[3]/div[2]/table/tbody').find_elements(By.TAG_NAME, 'a')
for idx, item in enumerate(all_a_in_td):
print(item.get_attribute("href"))
all_url_list.append(item.get_attribute("href"))
for idx, item in enumerate(all_url_list):
driver.execute_script("window.open('');")
driver.switch_to.window(driver.window_handles[idx + 1])
driver.get(item)
# driver.find_element(By.TAG_NAME, "body").send_keys()
time.sleep(2)
try:
driver.find_element(By.XPATH, '/html/body/div[2]/div[3]/div[2]/ul/li[1]/a[2]/h2').click()
except:
print('others')
time.sleep(.2)
url_len = len(all_url_list)
while True:
time.sleep(4 * 60)
for i in range(url_len):
driver.switch_to.window(driver.window_handles[i + 1])
driver.refresh()答题脚本
几秒内100%正确答题完成
- 需要浏览器先安装Tampermonkey
- 下载脚本,地址:https://greasyfork.org/zh-CN/scripts/391130
- 打开答题网页,脚本将自动执行:http://10.22.107.77/redir.php?catalog_id=6&cmd=dati
此脚本已经适配宁波大学,如果不适配或者答题网页的url发生变化,请在自行修改脚本,将下面的10.22.107.77换成新的答题网页url后放在脚本内(很明显就知道放在哪儿),注意’//'不可去除
// @match http://10.22.107.77/redir.php?catalog_id=6&cmd=dati
// @match http://10.22.107.77/redir.php?catalog_id=6&cmd=dati&moni=*- 文章作者:
- Lthero博客
- 版权声明:
- 本博客所有文章除特别声明外,均采用CC BY-NC-SA 4.0许可协议。转载请注明来自 Lthero博客!




