我正在使用 puppeteer 和 puppeteer-extra-plugin-recaptcha 插件。我想为 2captcha 解决设置自定义超时,但我很难。我使用的方法是:
await page.solveRecaptchas()
但是我在插件文档中找不到任何与超时相关的内容,我尝试了多种猜测类型的解决方案page.setDefaultTimeout(x)
,page.solveRecaptchas({timeout: x})
但没有一个有效。
任何帮助深表感谢
我正在使用 puppeteer 和 puppeteer-extra-plugin-recaptcha 插件。我想为 2captcha 解决设置自定义超时,但我很难。我使用的方法是:
await page.solveRecaptchas()
但是我在插件文档中找不到任何与超时相关的内容,我尝试了多种猜测类型的解决方案page.setDefaultTimeout(x)
,page.solveRecaptchas({timeout: x})
但没有一个有效。
任何帮助深表感谢
不要将超时与计时器一起使用。如果此设置为 true,请检查“复选框”的 [aria-checked],然后继续。
const frame = page.frames().find(async (frame) => await frame.title() === 'reCAPTCHA')
// You can choose between these two methods below
// Try this lines below
const checkmark = await frame.waitForSelector('#recaptcha-anchor', {visible: true})
while (await frame.evaluateHandle((checkmark) => checkmark.getAttribute('aria-checked') !== 'true', checkmark)) {
await page.waitForTimeout(100)
}
// Or simply this lines below
await frame.waitForFunction(() => {
return document.querySelector('#recaptcha-anchor').getAttribute('aria-checked') === 'true'
}, {timeout: 0, polling: 100})
// Then you can check
// reCaptcha solved successfully