-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.py
57 lines (43 loc) · 1.43 KB
/
main.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
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
# time for user to enter password (second)
wait_time = 10
# time for driver to load pages (second)
req_timeout = 4
# time gap between two search (second)
query_gap = 1
driver = webdriver.Chrome()
driver.implicitly_wait(req_timeout)
driver.maximize_window()
# your phone number, password, lessonId
username = ""
password = ""
lessonId = ""
def login():
driver.get("http://www.ehuixue.cn/")
driver.implicitly_wait(req_timeout)
driver.get("http://www.ehuixue.cn/index/login/login.html")
driver.implicitly_wait(req_timeout)
driver.find_element(By.NAME, "account").send_keys(username)
driver.find_element(By.NAME, "pwd").send_keys(password)
time.sleep(wait_time)
driver.execute_script("saveinfo()")
time.sleep(req_timeout)
# if you use https, you have to use flash player
driver.get("http://www.ehuixue.cn/index/study/inclass.html?cid=" + lessonId)
def start_watch():
driver.implicitly_wait(req_timeout)
driver.find_element(By.CLASS_NAME, "cview").click()
while True:
driver.implicitly_wait(query_gap)
try:
nxt = driver.find_element(By.CLASS_NAME, "layui-btn.layui-btn-normal.layui-btn-xs")
nxt.click()
return True
except:
print("No 'next' button!")
login()
while start_watch():
print("Next section start!")
print("Unknown error!")