From da8a3404ae1ffa514d4f6f1bf87b3d37a2cb0a96 Mon Sep 17 00:00:00 2001 From: JesterHey Date: Thu, 14 Mar 2024 11:07:32 +0800 Subject: [PATCH 1/7] new file: .vscode/c_cpp_properties.json new file: .vscode/launch.json new file: .vscode/settings.json modified: __pycache__/get_in.cpython-310.pyc modified: __pycache__/get_info.cpython-310.pyc modified: __pycache__/initialization.cpython-310.pyc modified: __pycache__/kill_course.cpython-310.pyc modified: __pycache__/single_course.cpython-310.pyc deleted: course_info.json modified: demo.py modified: get_info.py deleted: info.json new file: requirements.txt modified: single_course.py --- .vscode/c_cpp_properties.json | 18 +++++++ .vscode/launch.json | 13 +++++ .vscode/settings.json | 59 +++++++++++++++++++++ __pycache__/get_in.cpython-310.pyc | Bin 1907 -> 1904 bytes __pycache__/get_info.cpython-310.pyc | Bin 2884 -> 3010 bytes __pycache__/initialization.cpython-310.pyc | Bin 4540 -> 4535 bytes __pycache__/kill_course.cpython-310.pyc | Bin 1550 -> 1547 bytes __pycache__/single_course.cpython-310.pyc | Bin 2782 -> 2907 bytes course_info.json | 1 - demo.py | 30 +++++++---- get_info.py | 25 +++++---- info.json | 1 - requirements.txt | 3 ++ single_course.py | 23 +++++--- 14 files changed, 143 insertions(+), 30 deletions(-) create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json delete mode 100644 course_info.json delete mode 100644 info.json create mode 100644 requirements.txt diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..980fd57 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "macos-clang-arm64", + "includePath": [ + "${workspaceFolder}/**" + ], + "compilerPath": "/usr/bin/clang", + "cStandard": "${default}", + "cppStandard": "${default}", + "intelliSenseMode": "macos-clang-arm64", + "compilerArgs": [ + "" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..e103b05 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,13 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "C/C++ Runner: Debug Session", + "type": "lldb", + "request": "launch", + "args": [], + "cwd": "/Users/xuxiaolan/PycharmProjects/cyan_horse", + "program": "/Users/xuxiaolan/PycharmProjects/cyan_horse/build/Debug/outDebug" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..b9c6ac8 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,59 @@ +{ + "C_Cpp_Runner.cCompilerPath": "clang", + "C_Cpp_Runner.cppCompilerPath": "clang++", + "C_Cpp_Runner.debuggerPath": "lldb", + "C_Cpp_Runner.cStandard": "", + "C_Cpp_Runner.cppStandard": "", + "C_Cpp_Runner.msvcBatchPath": "", + "C_Cpp_Runner.useMsvc": false, + "C_Cpp_Runner.warnings": [ + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wshadow", + "-Wformat=2", + "-Wcast-align", + "-Wconversion", + "-Wsign-conversion", + "-Wnull-dereference" + ], + "C_Cpp_Runner.msvcWarnings": [ + "/W4", + "/permissive-", + "/w14242", + "/w14287", + "/w14296", + "/w14311", + "/w14826", + "/w44062", + "/w44242", + "/w14905", + "/w14906", + "/w14263", + "/w44265", + "/w14928" + ], + "C_Cpp_Runner.enableWarnings": true, + "C_Cpp_Runner.warningsAsError": false, + "C_Cpp_Runner.compilerArgs": [], + "C_Cpp_Runner.linkerArgs": [], + "C_Cpp_Runner.includePaths": [], + "C_Cpp_Runner.includeSearch": [ + "*", + "**/*" + ], + "C_Cpp_Runner.excludeSearch": [ + "**/build", + "**/build/**", + "**/.*", + "**/.*/**", + "**/.vscode", + "**/.vscode/**" + ], + "C_Cpp_Runner.useAddressSanitizer": false, + "C_Cpp_Runner.useUndefinedSanitizer": false, + "C_Cpp_Runner.useLeakSanitizer": false, + "C_Cpp_Runner.showCompilationTime": false, + "C_Cpp_Runner.useLinkTimeOptimization": false, + "C_Cpp_Runner.msvcSecureNoWarnings": false +} \ No newline at end of file diff --git a/__pycache__/get_in.cpython-310.pyc b/__pycache__/get_in.cpython-310.pyc index 081c6af43e369f41d9ceecbbf9e4270d06f996d7..c2958d4835920cdbe42a84c5482e0b0fb97e1df7 100644 GIT binary patch delta 243 zcmey&_koW$pO=@50SLmvKc&iV zBe5tqpeR2pHMyi%Ke;k7FFqr`s5n)B@@1AOKz$jk-av8-tCI39HmA~(lKi||9Jz^^ zc{%y{1)99Kc*-;LQu52=%QI6-GHy-&$=WNg0<<}bx41MZH?t%@39O|^2`E-14$m_(y7&SS7CD_0s#VRJC(m5lsC|AMAz{pt7NY4-` zkPH$CD9X=DO)e>pNv=%Hi_gd}Do%}=e1T;OP-`lyH;~-Os-zsn=2TizlAjmFk(-#A zmy@4gpvfD>Q=XZZl3yNQo|#gT5jFW6Yp=XA(DEqW;?ktt%#!#du$Cf4pjeR{h)|lm zh%L!O3&_015g!jSDL!74?G}4Uc4l5lYEh9YND&i=kOmPjg?Wj&sqyg;bHIjy38l$C G>?#1>@<|{7 diff --git a/__pycache__/get_info.cpython-310.pyc b/__pycache__/get_info.cpython-310.pyc index c0e769198375ac8580014636f52736c56b9e76c3..a45feb6936fca3b924d45fea2780fb27cbc89019 100644 GIT binary patch delta 401 zcmX>ic1WBzpO=@50SK7WKBZpX$h($N*IYleIJKx)zoN7vGci9WF;73BGC3o$C^w)e zKPxr4q*y<>GBGbcBfqFPRe$m;#x%xRlLMJT7*9@K#$?A-WiJ8j-@uh5O_Xw_tU*oUrw3%V*UE}dwO21-~McI!?XEIU+kOwv~}t8SuHQN zEPL9&{ptF)=L;I2%~=0*!m?*;7e8OP?){#|&0AS`85t8MA7<5-VPfQB5@6zC5@6(G w;$h@tWMX7#0Mq}Om?!^Xm1MrdqP$sx?J+Z>+vY!<_KciH9QtgGT#PLL00GB>yZ`_I delta 292 zcmX>kengBnpO=@50SKOK{Fv&$k#{YlfmMoCOhBb`Mq*K}f{}rdv7V8hAy6P0BoI)P zpOuWFqE+zpc9wq@s zJ|-SUCMG^c5Q~qIrGbZ$i;)kAnf|h{@G!DGWRcrEjqNcrqvPf(E_+5!T@HOVpe)Nj E0986kj{pDw diff --git a/__pycache__/initialization.cpython-310.pyc b/__pycache__/initialization.cpython-310.pyc index c454009b0d828c3bd43a1c909e323112f992e2eb..d71d51f34c9ea9566ea8b68bcd340752174dd742 100644 GIT binary patch delta 89 zcmdm^yj__upO=@50SLmvKc)5yZ{&N-qHC)kTAW%`tY1-Dk(rpElbEL;P??;OSd<%3 ql%JKFTvDu`T$z{`pOIfwoT@)rkyVL{4QK!xg8-w@|IPlaxjX<6dK<$4 delta 94 zcmdn4yhoWYpO=@50SJEX_?RjpvXSpGi-ALmRZKvob4FrOu7Z()k+GhUo*_^m86*%; sl%JKFTv8m9T$z{`pOIfwoEkG(j#Y_=184>tgAgOve>TR=UaYx10Cdh9;Q#;t diff --git a/__pycache__/kill_course.cpython-310.pyc b/__pycache__/kill_course.cpython-310.pyc index ef43deff6232f181a2d468df720f56b74da9bca8..6142be64b987f6535e4b177dd8482f3d4d85d809 100644 GIT binary patch delta 90 zcmeC<>E_|h=jG*M0D`daPpJ+Yc@3F$t@J~SQ;UlAD@rRe6Z3Nt^YjBMlQR;Fas!I; rvr>~wiuIE#6Z7IT@{5X7^(W^s|747soWb&fQGRkDYYC7%#_9n8{DB@2 delta 93 zcmeC?>Eq$e=jG*M00OpMA5#l9@)|N5*rr&;1XMa_Bo^f=7#SED>lx`80tJ#m0s%$& rS*gh-#WBg1iFxrE`9;O4F_W{Ie=^>hoXYZoQDL$lYYC7%%<2IE7AYQJ diff --git a/__pycache__/single_course.cpython-310.pyc b/__pycache__/single_course.cpython-310.pyc index 1a61d50e6c9400eb054455a13c561963a0f8303a..dd5d6634f4636428e08b3484d0f81e5e8128ef9a 100644 GIT binary patch delta 863 zcma))O=uHA6vyXHrr8g(+ca&Ow6WUy1yyV)QUvj!RuMrV7NuH{5_guiY28g`w=}6+ z5-55TD&xU}LUQoqAb8NLhzBp8Jyj6&=0Oid@Yeb^wHT^`3;)M^^ZxVZ_h3IJKXjX} zVdwa0P4I7+ilZPnw%(HQaLl}CVGAXkY43-Scrm+J5nfnHE~FVEbfJ!Bag0HpL%-lTo| zJL_G1S3Mc*Xf#g)jVGqS?+&zO=pwUJ{O~*LDfx;HR%aGFnmGNNI4dBuCcr=ofF1&@ zK&7h%fsB(tJ58>QF2#ZvPs~Q}<^e0e7C&gGqKu3}B+#f_YB3%2EZS*wzFCZ}ED*;#o| z*$L<5S>>}48!FnuvK{}DUH0X$8kokZyl0;&TXxZ(aUJtA)%xL`yrKQRR*CRBXitcb~w1xuqJ!YtD+kCtKVWjWr e7q%`&WJWK=4&g4V?7HjD;lX|VWLp7eZ~O$_9?QZ2 delta 728 zcma))&1(}u7{=$FO!h0uk|s@J(xk?ZOBF+#+Ji+Z67eF19E4g)DRC#H`RH!5S*?)` z25OH&%UnG4up(!Gqw*5AYyf#5lXQSTEwj3-9ynGe4ezd7FHfP>o1L zLEiW5Ywbm9SN)a_7cixZLt}k37Vv153$K?(c#Jkhqwrk zF8VrkpxF(4dO2#1*-BHQ89K3z(`XA^0MyyHW$t8XayyVleVJxy?g6spEBt>yWW}5~ zopi?Skn5*;HdY5KVar=Ej#}9K$P-ES8c(fUzZdljK#YNC1p6iDCj0WI)9# zL?H$WRzL*|LKc4@qRMwN;7Py(DWHJjZ6nD)?d_c9I|2wiB>?#zR-|wL$i int: + n = len(nums) + i = n - 1 + while i > 0 and len(nums) > 1: + cur = nums[i] + formal = nums[i - 1] + if formal <= cur: + cur += formal + nums[i] = cur + nums.pop(i - 1) + i = len(nums) - 1 + else: + i -= 1 + return max(nums) + +s = Solution() +print(s.maxArrayValue([5,3,3])) +print(s.maxArrayValue([2,3,7,9,3])) \ No newline at end of file diff --git a/get_info.py b/get_info.py index 6b0ff96..a6c7cf1 100644 --- a/get_info.py +++ b/get_info.py @@ -37,16 +37,21 @@ def login(first: bool = True, init: bool = False, username: str = None, pwd: str # 定位到账号文本框,获取文本框元素 ele = page.ele('#userName') # 的意思是通过id定位元素 - # 输入对文本框输入账号 - ele.input(username) - # 定位到密码文本框并输入密码 - page.ele('#password').input(pwd) - # 定位到验证码文本框并输入验证码 - inpcode = page.ele('#yzcode').text # 湖南青马太可爱了吧,验证码居然直接放在页面源码里:) - page.ele('#inpcode').input(inpcode) - # 点击登录按钮 - page.ele('#btnLogin').click() - page.wait.new_tab(3) + try: + # 输入对文本框输入账号 + ele.input(username) + # 定位到密码文本框并输入密码 + page.ele('#password').input(pwd) + # 定位到验证码文本框并输入验证码 + inpcode = page.ele('#yzcode').text # 湖南青马太可爱了吧,验证码居然直接放在页面源码里:) + page.ele('#inpcode').input(inpcode) + # 点击登录按钮 + page.ele('#btnLogin').click() + page.wait.new_tab(3) + if page.ele('@onclick=cha()',timeout=3): + pass + except BaseException: + logger.error('登录错误,请检查输入的账号密码是否正确!') # 进入课程页面 try: if page.ele('@onclick=cha()', timeout=3): diff --git a/info.json b/info.json deleted file mode 100644 index 3e13eb7..0000000 --- a/info.json +++ /dev/null @@ -1 +0,0 @@ -{"username": "51140220050507901X", "password": "hnqm123456", "study_type": "\u7f51\u7edc\u6587\u660e\u5fd7\u613f\u8005"} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..77275ae --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +DrissionPage==4.0.4.8 +DrissionPage==4.0.4.11 +loguru==0.7.2 diff --git a/single_course.py b/single_course.py index 5f46744..b142220 100644 --- a/single_course.py +++ b/single_course.py @@ -49,11 +49,14 @@ def one_course(cid: str, ctype: str, crate: int, again: bool = False): print('当前课程已完成') cur_page.close_tabs(tabs_or_ids=[tab]) # 进入后,获得当前视频的完成率,决定操作方式 - if tab.ele('tag:a@@text():继续学习', timeout=2): - tab.ele('tag:a@@text():继续学习').click() - else: - tab.ele( - 'c:#normalModel_video > xg-start > div.xgplayer-icon-play > svg > path').click() + try: + if tab.ele('tag:a@@text():继续学习', timeout=2): + tab.ele('tag:a@@text():继续学习').click() + else: + tab.ele( + 'c:#normalModel_video > xg-start > div.xgplayer-icon-play > svg > path').click() + except BaseException: + pass # 建立循环,检测当前视频是否完播 '''
@@ -85,14 +88,17 @@ def one_course(cid: str, ctype: str, crate: int, again: bool = False): try: if tab.ele('tag:div@@text():本小结已经学习完,是否进入下一节?', timeout=2): tab.ele('tag:a@@text():是').click() - except: + except BaseException: pass finally: # 有时候没有弹窗提示,用以下方式手动检测 for i in l: if i != 100: - tab.ele('#normalModel_nodeList').eles( - 'tag:div')[l.index(i)].click() + pers = tab.eles('.percentText') + for p in pers: + if int(p.text[:-1]) < 100: + p.click() + break time.sleep(1) try: if tab.ele('c:#normalModel_video > xg-start > div.xgplayer-icon-play > svg > path', timeout=2): @@ -101,6 +107,7 @@ def one_course(cid: str, ctype: str, crate: int, again: bool = False): except: pass time.sleep(60) # 每次监测间隔60秒 + break # なぜここにbreakがいるのですか?あかしいなあ。 From 8c2ee298bccbd6fc6c03b76f9403574d9375ab18 Mon Sep 17 00:00:00 2001 From: JesterHey Date: Thu, 14 Mar 2024 11:34:42 +0800 Subject: [PATCH 2/7] modified: requirements.txt --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 77275ae..055eb21 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ DrissionPage==4.0.4.8 -DrissionPage==4.0.4.11 loguru==0.7.2 From fdcf4e4536b0422895c1e81fff49f83e6d52b94f Mon Sep 17 00:00:00 2001 From: JesterHey Date: Thu, 14 Mar 2024 11:46:06 +0800 Subject: [PATCH 3/7] deleted: demo.py modified: requirements.txt --- demo.py | 20 -------------------- requirements.txt | 1 + 2 files changed, 1 insertion(+), 20 deletions(-) delete mode 100644 demo.py diff --git a/demo.py b/demo.py deleted file mode 100644 index edc629b..0000000 --- a/demo.py +++ /dev/null @@ -1,20 +0,0 @@ -from typing import List -class Solution: - def maxArrayValue(self, nums: List[int]) -> int: - n = len(nums) - i = n - 1 - while i > 0 and len(nums) > 1: - cur = nums[i] - formal = nums[i - 1] - if formal <= cur: - cur += formal - nums[i] = cur - nums.pop(i - 1) - i = len(nums) - 1 - else: - i -= 1 - return max(nums) - -s = Solution() -print(s.maxArrayValue([5,3,3])) -print(s.maxArrayValue([2,3,7,9,3])) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 055eb21..77275ae 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ DrissionPage==4.0.4.8 +DrissionPage==4.0.4.11 loguru==0.7.2 From 565e13699463396261e37ea7e8fc3abdc29eee44 Mon Sep 17 00:00:00 2001 From: JesterHey <144512889+JesterHey@users.noreply.github.com> Date: Thu, 14 Mar 2024 13:22:11 +0800 Subject: [PATCH 4/7] Create README.md --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..498deb7 --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# 🍏青马助手🐎 +## 前置要求 + + - 环境变量 Python >= 3.8 + - Chrome浏览器 +## 使用方法 +1. __下载程序(以下任选其一)__ +- 使用git克隆仓库 +```git clone https://github.com/JesterHey/cyan_horse.git``` +- 下载压缩包 +[点此下载](https://github.com/JesterHey/cyan_horse/archive/refs/heads/main.zip) +2. __安装所需库__ +在文件夹位置进入终端页面(压缩包下载者需解压后进入),输入代码: +```pip install requirements.txt``` +后等待下载完毕 +3. __运行__ +输入 +```python main.py``` +后程序自动开始执行,按要求填入信息即可 +## 常见问题 +1. 网络连接错误 +> 首先检查网络是否通畅,然后关闭程序后再重新按照上述步骤重新打开程序即可。 +2. 提示找不到元素或元素不存在 +> 由于青马网站加载限制和网络波动,有时候页面尚未完全加载时程序便开始执行下一步操作,因而产生此错误,解决方法同上。 +3. 课程信息识别有误 +> 问题产生原因在于读取课程信息时网站刷新不及时导致漏读,这回使得刷课时反复刷已经完成的课,解决方法也同上。 + +其他问题请在Issues中提出 + +## 免责声明 +使用程序即表示您愿意承担相应后果,原作者概不对其负责。 From 52b7dd584f0bbbc80b22f4ed0a660ce5e51b0164 Mon Sep 17 00:00:00 2001 From: JesterHey <144512889+JesterHey@users.noreply.github.com> Date: Thu, 14 Mar 2024 13:24:47 +0800 Subject: [PATCH 5/7] Create LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5fa2830 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 JesterHey + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 52b2a66b3182bb8d7a2a15660ed5c29d2eadb581 Mon Sep 17 00:00:00 2001 From: JesterHey <144512889+JesterHey@users.noreply.github.com> Date: Thu, 14 Mar 2024 13:28:00 +0800 Subject: [PATCH 6/7] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 498deb7..db41eac 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# 🍏青马助手🐎 +# 🍏青马助手🐎 beta1.0 ## 前置要求 - 环境变量 Python >= 3.8 @@ -27,5 +27,8 @@ 其他问题请在Issues中提出 +## TO DO +- [ ] 完成自动答题模块 + ## 免责声明 使用程序即表示您愿意承担相应后果,原作者概不对其负责。 From 6b66e3ff2ce81669e78b58f3bba78cfeb5bb24b0 Mon Sep 17 00:00:00 2001 From: JesterHey <144512889+JesterHey@users.noreply.github.com> Date: Fri, 15 Mar 2024 08:47:14 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index db41eac..6027e23 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ 在文件夹位置进入终端页面(压缩包下载者需解压后进入),输入代码: ```pip install requirements.txt``` 后等待下载完毕 -3. __运行__ +3. __运行__ 输入 ```python main.py``` 后程序自动开始执行,按要求填入信息即可