docs: align yunpan1 captcha code with tested flow
- 填值 + dispatchEvent (input/change) - 遍历 button 找"提交" - 弹窗不消失时导航到板块页面 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,12 +7,28 @@
|
||||
网站有时弹窗要求输入验证码。检测到输入框时填入:
|
||||
|
||||
```javascript
|
||||
const captchaInput = page.locator('input[placeholder*="验证码"]');
|
||||
if (await captchaInput.isVisible()) {
|
||||
await captchaInput.fill('392718');
|
||||
await page.locator('button:has-text("提交")').click();
|
||||
await page.waitForTimeout(2000);
|
||||
// 第一步:填入验证码
|
||||
await page.evaluate(() => {
|
||||
const input = document.querySelector('input[placeholder*="验证码"]');
|
||||
if (input) {
|
||||
input.value = '392718';
|
||||
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
input.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
}
|
||||
});
|
||||
|
||||
// 第二步:点击提交按钮
|
||||
await page.evaluate(() => {
|
||||
let target = null;
|
||||
document.querySelectorAll('button').forEach(b => {
|
||||
if (b.textContent.includes('提交')) target = b;
|
||||
});
|
||||
if (target) target.click();
|
||||
});
|
||||
|
||||
// 第三步:弹窗可能不自动消失,导航到板块页面即可
|
||||
await page.goto('https://yunpan1.cc/forum.php?mod=forumdisplay&fid=3');
|
||||
await page.waitForTimeout(2000);
|
||||
```
|
||||
|
||||
## 前置检查
|
||||
|
||||
Reference in New Issue
Block a user