栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python自动刷大学网课.

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python自动刷大学网课.

依赖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()
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/280420.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号