Python 宽学网
生活随笔
收集整理的這篇文章主要介紹了
Python 宽学网
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
油猴上沒有找到這個網站的插件就自己寫了一個,不到半小時搞定了原來需要50多個小時的時間。雖然初學編程遇到不少困難,但是這個小程序大大的鼓勵了自己。加油!!!!
import json import re from time import sleep import time import pyautogui from selenium import webdriver from selenium.webdriver.common.by import Bydriver = webdriver.Edge() # driver.get('http://czsh.kuanxue.com/') # print(driver.title) myclassroom=[] lessonover=[]def getcookie():diccookie = driver.get_cookies()fw = open('kuanxue.txt', 'w')json.dump(diccookie, fw)fw.close()def cookielogin():driver.get('http://czsh.kuanxue.com/')fr = open('kuanxue.txt', 'r')cookielist = json.load(fr)fr.close()for cookie in cookielist:driver.add_cookie(cookie)sleep(2)driver.get('http://czsh.kuanxue.com/lrm/controller/myCourse/search')driver.refresh()def mylesson():sleep(3)driver.get('http://czsh.kuanxue.com/lrm/controller/myCourse/search')driver.execute_script("searchCourseBySourceType('必修')")driver.execute_script("searchCourseByStatus('未學完')")page = driver.page_sourceurl_list = re.findall('href=\"(.*?)\"', page, re.S)for url in url_list:if "/lrm/controller/courseCenter/courseInfo?courseId=" in url:url = url.replace("/lrm/controller/courseCenter/courseInfo?courseId=", "")url = url.replace("&fromUrl=mycourse", "")if url not in myclassroom:myclassroom.append(url) return myclassroomdef gotoclassroom():sleep(3)if len(myclassroom) > 0:driver.get('http://czsh.kuanxue.com/lrm/controller/courseCenter/coursePlay?courseId='+str(myclassroom[0]))del myclassroom[0] playclass()else:mylesson()gotoclassroom()def lessonquick():sleep(4)pyautogui.click(x=1501,y=1050,button='left') # 進度條快進pyautogui.click(x=1501,y=1040,button='left') # 進度條快進pyautogui.click(x=1501,y=1030,button='left') # 進度條快進pyautogui.click(x=1501,y=1020,button='left') # 進度條快進pyautogui.click(x=1501,y=1010,button='left') # 進度條快進pyautogui.click(x=1501,y=1000,button='left') # 進度條快進 pyautogui.click(x=1501,y=990,button='left') # 進度條快進pyautogui.click(x=1501,y=980,button='left') # 進度條快進pyautogui.click(x=1501,y=970,button='left') # 進度條快進pyautogui.click(x=1501,y=960,button='left') # 進度條快進pyautogui.click(x=1501,y=950,button='left') # 進度條快進pyautogui.click(x=1501,y=940,button='left') # 進度條快進pyautogui.click(x=1501,y=930,button='left') # 進度條快進pyautogui.click(x=1501,y=920,button='left') # 進度條快進pyautogui.click(x=1501,y=910,button='left') # 進度條快進sleep(4)yv=[175,215,255,295,335,375,415,455,495]def playclass(): sleep(5)onclick_list = []page = driver.page_sourceonclicks = re.findall('onclick=\"coursePlayNew(.*?)\"', page, re.S)for onclick in onclicks:onclick_list.append(onclick)lessonnumber=0if len(onclick_list)>0 and lessonnumber<len(onclick_list):for yvalue in range(len(onclick_list)):startime = time.time()pyautogui.click(x=1665,y=yv[lessonnumber],button='left') sleep(3)lessonquick()lessonnumber+=1endtime = time.time()# print(endtime-startime)# print(lessonnumber)if lessonnumber==len(onclick_list):lessonover.append(driver.title)print(lessonover)gotoclassroom()總結
以上是生活随笔為你收集整理的Python 宽学网的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Vue过滤器 filter
- 下一篇: python中空位符_python中空位