This commit is contained in:
spiduler
2020-11-07 10:58:57 +09:00
parent f66e237c3e
commit 58fdc26514

View File

@@ -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))
})