Toggle navigation
Toggle navigation
This project
Loading...
Sign in
顾海波
/
xiaohongshu-skills
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Angiin
2026-03-08 01:37:24 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3ba7444fc677f7343ba2ea3d595036db14ab9087
3ba7444f
1 parent
3a8a8db1
fix: verify-code 前清空输入框,防止重试时验证码追加导致输入码错误
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletions
scripts/xhs/login.py
scripts/xhs/login.py
View file @
3ba7444
...
...
@@ -214,9 +214,21 @@ def submit_phone_code(page: Page, code: str) -> bool:
Returns:
True 登录成功,False 失败(超时或验证码错误)。
"""
# 点击验证码输入框
并
逐字输入
# 点击验证码输入框
,先清空已有内容(防止重试时追加导致验证码错误),再
逐字输入
page
.
click_element
(
CODE_INPUT
)
sleep_random
(
300
,
500
)
page
.
evaluate
(
f
"""(() => {{
const el = document.querySelector({json.dumps(CODE_INPUT)});
if (el && el.value) {{
const setter = Object.getOwnPropertyDescriptor(
window.HTMLInputElement.prototype, 'value'
).set;
setter.call(el, '');
el.dispatchEvent(new Event('input', {{ bubbles: true }}));
}}
}})()"""
)
page
.
type_text
(
code
,
delay_ms
=
100
)
sleep_random
(
500
,
800
)
...
...
Please
register
or
login
to post a comment