diff --git a/src/component/CaptchaComp.js b/src/component/CaptchaComp.js index 7452f60..211f4c5 100644 --- a/src/component/CaptchaComp.js +++ b/src/component/CaptchaComp.js @@ -37,7 +37,7 @@ class CaptchaComp { getUrl(params) { if (params.id) { - let params = Object.assign(this.params.res, { id: id }) + let params = Object.assign(this.params.res, { id: params.id }) let o = new url.URL(this.api.res) o.search = new url.URLSearchParams(params).toString(); return o @@ -74,13 +74,14 @@ class CaptchaComp { }) }) }).then(id => { - logger.info({ id: this.api.id }, 'Request answer delay for 20 senconds') + logger.info({ id: id }, 'Request answer delay for 20 senconds') return new Promise(r => setTimeout(() => r(id), 20000)) }) } - async getAnswer(res) { + async getAnswer(id) { let retryLimit = 10 + let res = await this.request({ id: id }) while (res.request == 'CAPCHA_NOT_READY') { await this.sleep(this.api.retryTimeout) retryLimit = retryLimit - 1 @@ -92,9 +93,8 @@ class CaptchaComp { } resolveCaptcha(driver) { - return this.requestResolve(driver) - .then(id => this.request({ id: id })) - .then(res => this.getAnswer(res)) + return this.requestResolve(driver) + .then(id => this.getAnswer(id)) .then(res => { return driver.executeScript('captchaCallback("' + res.request + '")').then(() => this.sleep(1000 * 5)) })