From 8f6a79872a813db5e137f17da398f675b2e78180 Mon Sep 17 00:00:00 2001 From: JesterHey Date: Tue, 12 Mar 2024 16:01:03 +0800 Subject: [PATCH] modified: __pycache__/get_info.cpython-310.pyc modified: demo.py modified: get_info.py modified: initialization.py --- __pycache__/get_info.cpython-310.pyc | Bin 2501 -> 2618 bytes demo.py | 28 +++++++++---- get_info.py | 10 +++-- initialization.py | 60 +++++++++++++++++++-------- 4 files changed, 70 insertions(+), 28 deletions(-) diff --git a/__pycache__/get_info.cpython-310.pyc b/__pycache__/get_info.cpython-310.pyc index 950e5ecef3462b2fcb54873360571e074ec60fdf..0fb95b6a8d5e1a871acf061cf15fa10ca3e9582f 100644 GIT binary patch delta 1547 zcmY*ZO>7%Q6rP!#{jt5f{z+&WL1;y!fJq@jm1s)~s-P+nhpMPSQ7s|M?2MC5oZWPG ztk%(5MsneR6i~IOCl2cqf)nD%jRQ9hNJt#^2saL>=U&R2aU9I9=I_0EZ{K_0x9^vQ zpBC3+&nqK%{=iT8V;`Zv)M5TH;cy*B^7W(j%?}YHz48`fCdXaEEM`BXtqQBNGIv>p zyIsm$<~=l99&0EW-0@iz&OWcQ+CCAR+#e&1m~lss=E9@z-`p(B;IOm913dR#wKrhA zr#^iirWECf;R(+11RUrSnVlHAgPO*z?1`~HB89`{8;WEk3mQhD3qLnpHfsik18f|h8EhUBQ8l0D2Y zBg{A^Vo8$RV03~p+D7WuHi~?TBps|_NF5`sHBoB5~b>ICmOL#lN(rAz6lt`6st#)RyZ z^HGHXEEpY~(>XOxa{5%8HfC2NUuzdmv|noN!b}TcpVj$(I~Vq%@+#fjW6w!{M}I?B z6_-wGfRi6(EhUXHTvJ7xjpmu`3-Y;Fn1V|&5H*0I$X1Ns-DX`VjD!tSc7M=H!-yc0%M*e17NqL^ZfWarK6 zBT8LN|D-Eo73BXTJN$S5@#8Jvhvo&AI7KQQjWOma)< zLSPj$hlaFshgrIErBP~(@eTCx`+y_PO=bh`W@_eT=D^NMEzqqE?bP0@|QP(;z#n1cKU zN*-rFTdS6;pr~elTX%6IyJ5FpS)78aN?lMH9zaJ(dYm5?w%}dClUtSr`_LKMA!}s==fbM$DRam>vyO2EOG|I7Ae?slpc6*zc9U$~Y~rnEEjv@XI=Y~IsJn#)#OaH^P|ZTTs3mf67)Cpq zh6Vj3j(eIqV&*UE9PoB~j(|EK%|hqeLCpF+{*LOS$qO*mkb|eMt5=^c8nss~XRVCs Gvws1x`C4-T delta 1457 zcmZvc&u<$=6vtQ{JG$3|0v-{q6-<$V#KD*ym zf2b^no|i{({8Igs{p2I`n=~#T1dMwyqT%!9hZ`<6S$JFXRIhqICWgc~o zHNMH*3Bri#kJPAn&%b|t{5UiA10IPMzLeg8dmF|Bxxxpa#3&*ZJwgIa&!gT>VU`m6-}<&#QjFzEpNqW)*%~ zpmU;lpwfv6`dMr~X(xG5t@uX(^SJ?se% zw4u5cbbGCkvab-o2KHZf=$*ao!Gpsl@4T}1>e~A1+Ujj^w4`I3hexa>qP^Cj*=-z# zJYstXP(aY#4_AAG%xH%PLDzva(Kbv36KrZGwy}njsd0DglQJg1@+Hvz1z`ak7Z5%K z2>%a0p~q+3>U^Xv zKyf1%JO*f9?8Z*)QTGb~HqLLMr}twc9uw-#qhp;vQ%eH1XZ5Mtfn0X(26% za;#6FOI2)z7HMgseOeg#qMFV@N`I=IeRKp7G|}Nx2WoDk=*ttxBF|kIilp+pze`+( z_PzI$ZObw(Fu0vOv39YOd}GzuuDrmBds39!lMxYgSY||R#(H&&vwhB@Lq!aqOWw4v z;cBvDzu^@WRQx3w_j2;NePb!p1&=aK@VedVbA?8hYlVGar4i69`Pp8%Awg5L@kP0o zJ!5DCtY{0SGis8R+(u4{FU*m(nH=0 x!?x;!&%(RS4r?^d7X9z?Tb+>h+w89VFGlk)6_E|l%F~5WB*hi`W*(Ej{{hDJOV0oR diff --git a/demo.py b/demo.py index 6e12363..38451ce 100644 --- a/demo.py +++ b/demo.py @@ -1,8 +1,20 @@ -from collections import * -import json -info = json.load(open('course_info.json','r')) -cnt = Counter(info[k]['type'] for k in info.keys()) -print(cnt) -cnt['必修'] = 1 -less_10 = [k for k, v in cnt.items() if v < 10] -print(less_10) \ No newline at end of file +from DrissionPage import ChromiumPage +from DrissionPage.common import * +from loguru import logger +import subprocess +from get_info import login +# page = ChromiumPage() +# page.get('http://hnqmgc.17el.cn/') +# try: +# if page.ele('@onclick=cha()',timeout=3): +# page.ele('@onclick=cha()').click() +# # +# elif page.ele('tag:img@@style=width: 25px;height: 25px;',timeout=3): +# page.ele('tag:img@@style=width: 25px;height: 25px;').click() +# except BaseException: +# logger.error('不能进入课程页面') +# subprocess.run(["python", __file__]) +# exit() +# page.ele('tag:a@@text():青马课堂').hover() +# page.ele('tag:a@@text():全部').click().for_new_tab() +login(first=True,init=True) \ No newline at end of file diff --git a/get_info.py b/get_info.py index 6ffd5f2..96fdd42 100644 --- a/get_info.py +++ b/get_info.py @@ -5,10 +5,14 @@ import time import json from loguru import logger import subprocess +from typing import * # http://hnqmgc.17el.cn/grzx/ # 单独实现登录操作 -def login(first:bool=True): +def get_into_center(cpage:ChromiumPage): + cpage.ele('#login_btn').click() + cpage.ele('@value=进入个人中心').click() +def login(first:bool=True,init:bool=False): if not first: return # 先检查当前页面是否已经登录 @@ -48,8 +52,8 @@ def login(first:bool=True): logger.error('不能进入课程页面') subprocess.run(["python", __file__]) exit() - page.ele('#login_btn').click() - page.ele('@value=进入个人中心').click() + if not init: + get_into_center(page) def get_info(first:bool=True): # 创建页面对象,并启动或接管浏览器 page = ChromiumPage() diff --git a/initialization.py b/initialization.py index 0da9989..7ef9024 100644 --- a/initialization.py +++ b/initialization.py @@ -11,25 +11,51 @@ import time from loguru import logger from get_info import get_info from collections import * +from get_info import login -# 读取课程数量信息 -get_info() -class_info = json.load(open('course_info.json','r')) -# 读取各个类别的课程数量 -cnt = Counter(class_info[k]['type'] for k in class_info.keys()) -# 检测是否存在小于10的课程数量 -less_10 = [k for k, v in cnt.items() if v < 10] -def click_videoes(): +def click_videoes(study_type:str) -> None: ''' - 进入首页,逐个点击相应视频,每个视频页面停留3秒后推出,并进入下一个视频。 + study_type:只能在如下选项中选择 + 1、入党积极分子 + 2、网络文明志愿者 + 3、团学干部 + 4、大学生心理健康教育 ''' - pass -if not less_10: - # 直接进行刷课和检测 - pass -else: + # 由于各位学员的培训种类不同,这里交给用户输入 + + # 必修,选修,专栏学习是每人都要学习的,统一处理 + def must_study(): + pass + def elective_study(): + pass + def column_study(): + pass + + +# 读取课程数量信息 +def init(): ''' - 回到首页,逐个点击相应视频,每个视频页面停留3秒后推出,并进入下一个视频。 - 结束调用get_info()函数,更新课程数量信息 + 初始化,检测是否需要进入视频一次页以及进行进入视频一次页操作 ''' - pass + # 获取课程数量信息 + get_info() + class_info = json.load(open('course_info.json','r')) + # 读取各个类别的课程数量 + cnt = Counter(class_info[k]['type'] for k in class_info.keys()) + # 检测是否存在小于10的课程数量 + less_10 = [k for k, v in cnt.items() if v < 10] + if not less_10: + # 直接进行刷课和检测 + return + else: + ''' + 回到首页,逐个点击相应视频,每个视频页面停留3秒后推出,并进入下一个视频。 + 结束调用get_info()函数,更新课程数量信息 + ''' + # 接管当前页面 + page = ChromiumPage() + # 进入青马课堂页 + login(first=True,init=True) + page.ele('tag:a@@text():青马课堂').hover() + page.ele('tag:a@@text():全部').click().for_new_tab() + click_videoes() \ No newline at end of file