This commit is contained in:
ddrwode
2026-02-27 18:37:48 +08:00
parent a159ea31cc
commit 56fc070a50
2 changed files with 279 additions and 37 deletions

259
1.html

File diff suppressed because one or more lines are too long

View File

@@ -695,7 +695,7 @@ def submit_phone(
page.get(url)
time.sleep(wait_page)
# 1. 勾选协议
# 1. 勾选协议1.html: #color-input-red
agree_checkbox = find_first(
page,
[
@@ -708,44 +708,41 @@ def submit_phone(
)
if agree_checkbox:
click_safe(agree_checkbox)
time.sleep(0.1)
# 2. 立即订购
order_btn = None
for attempt in range(4):
order_btn = find_first(
page,
[
"css:div.paybg",
"css:.paybg",
'x://button[contains(.,"立即订购")]',
'x://a[contains(.,"立即订购")]',
'x://span[contains(.,"立即订购")]',
'x://div[contains(.,"立即订购")]',
'x://*[contains(text(),"立即订购")]',
'x://*[contains(.,"立即订购")]',
"css:.btn-order",
"css:button.btn-primary",
"css:button.btn",
"css:a.btn",
],
timeout=1,
)
if order_btn:
break
time.sleep(0.08)
time.sleep(0.03)
# 2. 立即订购1.html: .paybg 手机端首选)
order_btn = find_first(
page,
[
"css:.paybg",
"css:div.paybg",
'x://button[contains(.,"立即订购")]',
'x://a[contains(.,"立即订购")]',
'x://span[contains(.,"立即订购")]',
'x://div[contains(.,"立即订购")]',
'x://*[contains(text(),"立即订购")]',
'x://*[contains(.,"立即订购")]',
"css:.btn-order",
"css:button.btn-primary",
"css:button.btn",
"css:a.btn",
],
timeout=3,
)
if order_btn:
try:
order_btn.run_js("this.scrollIntoView({block:'center'})")
time.sleep(0.02)
time.sleep(0.01)
except Exception:
pass
click_safe(order_btn)
time.sleep(0.1)
time.sleep(0.05)
else:
# 兜底1.html 的 .paybg 为 div用 JS 直接点
try:
page.run_js("""
var btn = document.querySelector('.paybg');
if (btn) { btn.scrollIntoView({block:'center'}); btn.click(); return true; }
var nodes = document.querySelectorAll('button, a, span, div');
for (var i = 0; i < nodes.length; i++) {
var t = (nodes[i].innerText || nodes[i].textContent || '').trim();
@@ -759,7 +756,7 @@ def submit_phone(
""")
except Exception:
pass
time.sleep(0.1)
time.sleep(0.05)
# 3. 输入手机号
phone_input = find_first(