更新webpage_login() 适配新的统一认证api#9
Open
zeroHYH wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
该 PR 旨在更新 webpage_login() 以适配新的统一认证(CAS/device)接口交互方式,并同步重构登录加密(DES)实现以提升性能/可维护性,同时对课表抓取的 BeautifulSoup 用法和项目依赖版本做了更新。
Changes:
- 重写
uniform_login_des.py:用位运算 + LUT + 缓存替代原先的逐 bit 列表实现的 DES/3DES 风格加密流程。 - 更新
webpage_login():改用httpx.Client()复用会话/cookies,并调整 device 接口参数(m=1/2/3)与提交登录表单逻辑。 - 将
findAll()替换为find_all(),并升级httpx/bs4/pandas/sqlmodel依赖下限。
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/login/uniform_login_des.py |
重构 DES 加密实现(LUT + 缓存)以支撑新的统一认证加密/性能需求。 |
src/login/main.py |
调整网页登录与设备校验流程,适配新的统一认证 device/login 参数与会话管理。 |
src/bkzhjx_login.py |
将 BeautifulSoup 旧 API findAll 更新为 find_all。 |
pyproject.toml |
提升关键依赖的最低版本要求以匹配新实现/调用方式。 |
Comments suppressed due to low confidence (1)
src/login/main.py:74
- Raising SystemError for a missing hidden field is misleading because SystemError is meant for interpreter-level failures. Consider raising a RuntimeError/ValueError (and ideally include status code / a short response snippet) so callers can handle login-page changes appropriately.
if not match:
raise SystemError(
f"Cannot find {field} in login page. Check service URL or login page changes."
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -63,114 +63,162 @@ def webpage_login( | |||
| """ | |||
| Using webpage to login, powered by execjs, BeautifulSoup4 to parse the html and httpx to send requests. | |||
Comment on lines
+67
to
+70
| match = re.search( | ||
| rf'(?:name|id)=[\'\"]{re.escape(field)}[\'\"]\s+value=[\'\"](.*?)[\'\"]', | ||
| html, | ||
| ) |
| case "binded" | "pass": | ||
| pass | ||
| case "bind": | ||
| print("2FA:" + device_status_dict.get("m")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.