catch error for 2captcha

This commit is contained in:
2022-09-08 11:34:54 +02:00
parent ee5f6a8c6b
commit 3557a2ed90
+19 -13
View File
@@ -39,26 +39,32 @@ class SolveCaptcha {
status_code = status;
solution = sol
})
await delay(5 * 1000)
}
handle_solution_received(solution)
}
async get_solution(catcha_id, onSolutionFound) {
console.log("get_solution() called")
let url_response = `http://2captcha.com/res.php?key=${API_KEY}&action=get&id=${catcha_id}`;
let res = await axios.get(url_response)
console.log(`statusCode: ${res.status}`);
console.log(res);
let results = res.data.split("|");
let solution
if (results.length > 1)
solution = results[1];
else {
solution = results[0]
try {
let url_response = `http://2captcha.com/res.php?key=${API_KEY}&action=get&id=${catcha_id}`;
let res = await axios.get(url_response)
console.log(`statusCode: ${res.status}`);
// console.log(res);
let results = res.data.split("|");
let solution
if (results.length > 1)
solution = results[1];
else {
solution = results[0]
}
onSolutionFound(res.status, solution)
await delay(5 * 1000)
} catch (e) {
onSolutionFound(1, CAPCHA_NOT_READY)
await delay(5 * 1000)
}
onSolutionFound(res.status, solution)
await delay(5 * 1000)
}
}