try catch when 2captcha connection failed
This commit is contained in:
@@ -17,3 +17,7 @@ adb -s 76a3ac8d shell am start -n com.android.chrome/com.google.android.apps.chr
|
|||||||
adb -s 47e7e36b shell pm clear com.android.chrome
|
adb -s 47e7e36b shell pm clear com.android.chrome
|
||||||
adb -s 47e7e36b shell am set-debug-app --persistent com.android.chrome
|
adb -s 47e7e36b shell am set-debug-app --persistent com.android.chrome
|
||||||
adb -s 47e7e36b shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
adb -s 47e7e36b shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||||
|
#asus tab
|
||||||
|
adb -s 751005221815 shell pm clear com.android.chrome
|
||||||
|
adb -s 751005221815 shell am set-debug-app --persistent com.android.chrome
|
||||||
|
adb -s 751005221815 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const {_android: android, devices} = require("playwright");
|
const {_android: android, devices} = require("playwright");
|
||||||
|
|
||||||
const SolveCaptcha = require("./SolveCaptcha");
|
const {SolveCaptcha, TWO_CAPTCHA_CONNECTION_FAILED} = require("./SolveCaptcha");
|
||||||
const ReserveResultPojo = require("../models/ReserveResultPojo");
|
const ReserveResultPojo = require("../models/ReserveResultPojo");
|
||||||
const PublishType = require("../models/PublishType");
|
const PublishType = require("../models/PublishType");
|
||||||
|
|
||||||
@@ -174,13 +174,14 @@ class CommandorPage {
|
|||||||
async clickValid(page) {
|
async clickValid(page) {
|
||||||
await delay(getRandomWaitTime())
|
await delay(getRandomWaitTime())
|
||||||
try {
|
try {
|
||||||
|
if (!this.page.isClosed()){
|
||||||
this.page.evaluate(() => {
|
this.page.evaluate(() => {
|
||||||
document.getElementsByClassName("btn")[0].focus();
|
document.getElementsByClassName("btn")[0].focus();
|
||||||
})
|
})
|
||||||
await delay(getRandomWaitTime())
|
await delay(getRandomWaitTime())
|
||||||
this.page.evaluate(() => {
|
this.page.evaluate(() => {
|
||||||
document.getElementsByClassName("btn")[0].click();
|
document.getElementsByClassName("btn")[0].click();
|
||||||
})
|
})}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
@@ -194,7 +195,7 @@ class CommandorPage {
|
|||||||
this.captchaSolver = new SolveCaptcha(page);
|
this.captchaSolver = new SolveCaptcha(page);
|
||||||
await this.captchaSolver.start((solution) => {
|
await this.captchaSolver.start((solution) => {
|
||||||
console.log("solution is: " + solution);
|
console.log("solution is: " + solution);
|
||||||
if (solution !== ERROR_CAPTCHA_UNSOLVABLE) {
|
if (solution !== ERROR_CAPTCHA_UNSOLVABLE&&solution!==TWO_CAPTCHA_CONNECTION_FAILED) {
|
||||||
try {
|
try {
|
||||||
if (!page.isClosed()){
|
if (!page.isClosed()){
|
||||||
page.evaluate((solution) => {
|
page.evaluate((solution) => {
|
||||||
@@ -217,7 +218,7 @@ class CommandorPage {
|
|||||||
|
|
||||||
if (content.toString().includes(captcha_url)) {
|
if (content.toString().includes(captcha_url)) {
|
||||||
await this.checkAudioBtn();
|
await this.checkAudioBtn();
|
||||||
console.log("we are blocked");
|
console.log("发现datadome");
|
||||||
} else {
|
} else {
|
||||||
if (currentPage.url() === RDV_URL) {
|
if (currentPage.url() === RDV_URL) {
|
||||||
await this.fillFields(this.page);
|
await this.fillFields(this.page);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const axios = require("axios");
|
const axios = require("axios");
|
||||||
const CAPCHA_NOT_READY = "CAPCHA_NOT_READY";
|
const CAPCHA_NOT_READY = "CAPCHA_NOT_READY";
|
||||||
|
const TWO_CAPTCHA_CONNECTION_FAILED = "TWO_CAPTCHA_CONNECTION_FAILED";
|
||||||
const REGEX_DATA_SITE_KEY = "data-sitekey=[\"a-z0-9A-Z]+";
|
const REGEX_DATA_SITE_KEY = "data-sitekey=[\"a-z0-9A-Z]+";
|
||||||
const API_KEY = "d66aaf490d8aa424a5175e1fbd1aadea";
|
const API_KEY = "d66aaf490d8aa424a5175e1fbd1aadea";
|
||||||
const SITE_KEY = "6LdUViwUAAAAAOBJjtMsmKc9C7200Djd31w2mCs7";
|
const SITE_KEY = "6LdUViwUAAAAAOBJjtMsmKc9C7200Djd31w2mCs7";
|
||||||
@@ -24,8 +25,8 @@ class SolveCaptcha {
|
|||||||
|
|
||||||
async solve_captcha(site_key, handle_solution_received) {
|
async solve_captcha(site_key, handle_solution_received) {
|
||||||
console.log("solve_captcha(), for " + this.page.url())
|
console.log("solve_captcha(), for " + this.page.url())
|
||||||
|
try {
|
||||||
let url_get = `http://2captcha.com/in.php?key=${API_KEY}&method=userrecaptcha&googlekey=${site_key}&pageurl=${this.page.url()}`;
|
let url_get = `http://2captcha.com/in.php?key=${API_KEY}&method=userrecaptcha&googlekey=${site_key}&pageurl=${this.page.url()}`;
|
||||||
|
|
||||||
let res = await axios.get(url_get)
|
let res = await axios.get(url_get)
|
||||||
console.log(`statusCode: ${res.status}`);
|
console.log(`statusCode: ${res.status}`);
|
||||||
console.log(res);
|
console.log(res);
|
||||||
@@ -41,6 +42,11 @@ class SolveCaptcha {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
handle_solution_received(solution)
|
handle_solution_received(solution)
|
||||||
|
}catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
handle_solution_received(TWO_CAPTCHA_CONNECTION_FAILED)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async get_solution(catcha_id, onSolutionFound) {
|
async get_solution(catcha_id, onSolutionFound) {
|
||||||
@@ -68,4 +74,4 @@ class SolveCaptcha {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = SolveCaptcha
|
module.exports = {SolveCaptcha, TWO_CAPTCHA_CONNECTION_FAILED}
|
||||||
Reference in New Issue
Block a user