From 3d37edfebf6c2451326588253c695bcf77f7816d Mon Sep 17 00:00:00 2001 From: Kaxi <1042864399@qq.com> Date: Sat, 16 May 2026 22:00:36 +0800 Subject: [PATCH] docs: align yunpan1 captcha code with tested flow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 填值 + dispatchEvent (input/change) - 遍历 button 找"提交" - 弹窗不消失时导航到板块页面 Co-Authored-By: Claude Opus 4.6 --- sites/yunpan1/v1/usage.md | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/sites/yunpan1/v1/usage.md b/sites/yunpan1/v1/usage.md index b7b307d..76eea09 100644 --- a/sites/yunpan1/v1/usage.md +++ b/sites/yunpan1/v1/usage.md @@ -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); ``` ## 前置检查