can input numbers

This commit is contained in:
2022-09-27 23:43:39 +02:00
parent ba6c856eb4
commit 4df9e003e0
+11 -10
View File
@@ -61,21 +61,22 @@ class GeoCaptchaSolver {
let captcha_container = await iframeHandler.locator(CAPTCHA_CONTAINER) let captcha_container = await iframeHandler.locator(CAPTCHA_CONTAINER)
let html = await captcha_container.innerHTML() let html = await captcha_container.innerHTML()
console.log("audio_tag: " + html); console.log("audio_tag: " + html);
let fieldInputs = await iframeHandler.locator("#captcha__audio > div.audio-captcha-input-container > input:nth-child(1)")
// find wav from html // find wav from html
await this.findTextFromWavFile(html, (number_list) => { await this.findTextFromWavFile(html, async (number_list) => {
for (i; i < number_list.length; i++) { for (let i = 1; i <= number_list.length; i++) {
this.page.evaluate((info) => { let selector = "#captcha__audio > div.audio-captcha-input-container > input:nth-child(" + i + ")"
let input_fileds = document.getElementsByClassName("audio-captcha-inputs"); console.log("selector is " + selector)
input_fileds[info.index].focus(); await iframeHandler.locator(selector).focus()
input_fileds[info.index].value = info.number; await iframeHandler.locator(selector).fill("" + number_list[i - 1])
}, {'index': i, 'number': number_list[i]}) // fieldInputs[i].value = number_list[i];
delay(getRandomWaitTime()); await delay(getRandomWaitTime());
} }
} }
) )
} }
async findTextFromWavFile(html) { async findTextFromWavFile(html, callback) {
let result = re.exec(html); let result = re.exec(html);
//create the directory if not exist //create the directory if not exist
await fs.promises.mkdir(dest_dir, {recursive: true}); await fs.promises.mkdir(dest_dir, {recursive: true});
@@ -89,7 +90,7 @@ class GeoCaptchaSolver {
} else { } else {
console.log('download the file successfully'); console.log('download the file successfully');
// send request to get numbers // send request to get numbers
sendRequest(fileName); sendRequest(dest_dir + fileName, callback);
} }
}) })
} }