Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -152,6 +152,8 @@ class Utils {
|
|
| 152 |
}
|
| 153 |
static async solveAwsWaf(images, questionType = 'aws:grid') {
|
| 154 |
try {
|
|
|
|
|
|
|
| 155 |
const response = await fetch('https://api.capsolver.com/createTask', {
|
| 156 |
method: 'POST',
|
| 157 |
headers: {
|
|
@@ -169,8 +171,14 @@ class Utils {
|
|
| 169 |
});
|
| 170 |
|
| 171 |
const data = await response.json();
|
| 172 |
-
if (data.errorId === 0
|
| 173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
}
|
| 175 |
return null;
|
| 176 |
} catch (error) {
|
|
@@ -211,6 +219,7 @@ class Utils {
|
|
| 211 |
const solution = await this.solveAwsWaf(screenshots, 'aws:grid');
|
| 212 |
|
| 213 |
if (solution?.objects) {
|
|
|
|
| 214 |
// 自动点击验证答案
|
| 215 |
await page.evaluate((objects) => {
|
| 216 |
document.querySelectorAll('.grid-item').forEach((el, index) => {
|
|
@@ -231,6 +240,12 @@ class Utils {
|
|
| 231 |
cookie => cookie.name.toLowerCase() === 'aws-waf-token'
|
| 232 |
)?.value;
|
| 233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
await browser.close();
|
| 235 |
return awsWafToken;
|
| 236 |
|
|
|
|
| 152 |
}
|
| 153 |
static async solveAwsWaf(images, questionType = 'aws:grid') {
|
| 154 |
try {
|
| 155 |
+
console.log(`开始Capsolver验证 (类型: ${questionType}), 图片数量: ${images.length}`);
|
| 156 |
+
|
| 157 |
const response = await fetch('https://api.capsolver.com/createTask', {
|
| 158 |
method: 'POST',
|
| 159 |
headers: {
|
|
|
|
| 171 |
});
|
| 172 |
|
| 173 |
const data = await response.json();
|
| 174 |
+
if (data.errorId === 0) {
|
| 175 |
+
if (data.status === 'ready') {
|
| 176 |
+
console.log(`✅ Capsolver验证成功 | 任务ID: ${data.taskId} | 使用图片: ${images.length}张`);
|
| 177 |
+
return data.solution;
|
| 178 |
+
}
|
| 179 |
+
console.log(`⏳ Capsolver处理中 | 任务ID: ${data.taskId} | 状态: ${data.status}`);
|
| 180 |
+
} else {
|
| 181 |
+
console.error(`❌ Capsolver错误 | 代码: ${data.errorCode} | 描述: ${data.errorDescription}`);
|
| 182 |
}
|
| 183 |
return null;
|
| 184 |
} catch (error) {
|
|
|
|
| 219 |
const solution = await this.solveAwsWaf(screenshots, 'aws:grid');
|
| 220 |
|
| 221 |
if (solution?.objects) {
|
| 222 |
+
console.log(`🎯 验证答案位置: ${solution.objects.join(', ')}`);
|
| 223 |
// 自动点击验证答案
|
| 224 |
await page.evaluate((objects) => {
|
| 225 |
document.querySelectorAll('.grid-item').forEach((el, index) => {
|
|
|
|
| 240 |
cookie => cookie.name.toLowerCase() === 'aws-waf-token'
|
| 241 |
)?.value;
|
| 242 |
|
| 243 |
+
if (awsWafToken) {
|
| 244 |
+
console.log(`🔑 成功获取aws-waf-token | 长度: ${awsWafToken.length}字符`);
|
| 245 |
+
} else {
|
| 246 |
+
console.error('❌ 获取aws-waf-token失败');
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
await browser.close();
|
| 250 |
return awsWafToken;
|
| 251 |
|