本帖最后由 wushaominkk 于 2019-9-25 08:28 编辑
目标网址:http://person.17el.cn//Authentication/loadlogin?params=customer
解决问题:所选课程全部自动化
运行环境:Python3、selenium、chrome
声明:仅限个人学习使用,严禁商业使用,否则后果自负(如有违规请版主删除)
[Python] 纯文本查看 复制代码 from selenium import webdriver
import time
import re
#输入本人账号
username="*****"
#输入本人密码
passwd="****"
login_url='http://person.17el.cn//Authentication/loadlogin?params=customer'
option = webdriver.ChromeOptions()
prefs = {
"profile.managed_default_content_settings.images": 1,
"profile.content_settings.plugin_whitelist.adobe-flash-player": 2,
"profile.content_settings.exceptions.plugins.*,*.per_resource.adobe-flash-player": 2,
}
option.add_experimental_option('prefs', prefs)
browser = webdriver.Chrome( chrome_options=option)
browser.maximize_window()
browser.get(login_url)
browser.implicitly_wait(10)
elem=browser.find_element_by_id("yhzh")
elem.send_keys(username)
time.sleep(1)
elem=browser.find_element_by_id("yhmm_input")
elem.send_keys(passwd)
time.sleep(2)
elem=browser.find_element_by_xpath('//*[@id="form"]/div[2]/div[3]/input')
elem.click()
time.sleep(3)
browser.get("http://person.17el.cn/pageclasscourse/getClassCourse?MENU=bjyd&xmid=&bjid=&secondMENU=bjkc&type=1")
time.sleep(3)
browser.find_element_by_id("1aid").click()
video_url=re.findall('href="(/flex/HXGC_Player.*?sfsc=0)"',browser.page_source)
video_time=re.findall('<span style="float:left;width:160px;background:#fff;border: 0;padding-left:20px;">总时长:(.*?)</span>',browser.page_source)
video_progress=re.findall('<span style="float:left;width:150px;background:#fff;border: 0;">学习进度:(.*?)%</span>',browser.page_source)
video_url_pool=[]
video_time_pool=[]
video_progress_pool=[]
for a,b,c in zip(video_url,video_time,video_progress):
if c!="100":
video_url_pool.append("http://person.17el.cn"+a)
video_time_pool.append(int(str(b)[:2]) * 3600 + int(str(b)[3:5]) * 60 + int(str(b)[-2:]))
video_progress_pool.append(1-int(c)/100)
for m,n,g in zip(video_url_pool,video_time_pool,video_progress_pool):
browser.get(m)
print("该视频还有多{}秒未学习".format(n*g))
time.sleep(n*g+100) |