依赖chrome阅览器与驱动,驱动需放在d盘根目录下.
设置.txt需自行创建格式为
账号:
密码:
from selenium import webdriver
import time
import sys
from selenium.common.exceptions import NoSuchElementException
import os
from lxml import etree
# print('请在文件夹里设置.txt键入账号密码,完成后按y继续')
# print('默认只刷五个视频,请反编译文件更改代码,exe没有加密')
with open('设置.txt', 'r',encoding='utf-8' ) as f:
username=f.readline()[3:-1]
password=f.readline()[3:-1]
timelist=[]
mark=0
wd = webdriver.Chrome(r'd:chromedriver.exe')
wd.get('http://hw.neusoft.edu.cn/hw/lrn/lrn.do?cno=74005TC088&teachingclassno=200485-005')
wd.find_element_by_id('username').send_keys(username)
wd.find_element_by_id('password').send_keys(password)
wd.find_element_by_class_name('btn-submit').click()
elements=wd.find_elements_by_xpath('//*[@]')
print(len(elements))
for i in elements:
i.click()
time.sleep(3)
n = wd.window_handles
print('当前句柄: ', n)
wd.switch_to_window(n[-1])
try:
vediotime=wd.find_element_by_xpath('//*[@id="myVideo"]/div[2]/div[7]/span[2]')
print(vediotime.get_attribute('textContent'))
timelist.append(vediotime.get_attribute('textContent'))
realvediotime=str(vediotime.get_attribute('textContent'))
m, s = realvediotime.strip().split(':')
smillisecond=int(m)*60 + int(s)
time.sleep(-smillisecond+10)
wd.close()
except Exception as re:
print(re)
print('错误,这不是一个视频,前往下一个链接')
wd.close()
wd.switch_to_window(n[0])
mark=mark+1
print(timelist)
print('已完成')
wd.quit()



