Spaces:
Sleeping
Sleeping
Update scrape/wgpt.js
Browse files- scrape/wgpt.js +14 -9
scrape/wgpt.js
CHANGED
|
@@ -16,6 +16,11 @@ class WormGPTScraper {
|
|
| 16 |
this.currentChatId = null;
|
| 17 |
}
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
generatePassword(length = 12) {
|
| 20 |
const uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
| 21 |
const lowercase = 'abcdefghijklmnopqrstuvwxyz';
|
|
@@ -61,14 +66,14 @@ class WormGPTScraper {
|
|
| 61 |
const page = await browser.newPage();
|
| 62 |
|
| 63 |
await page.goto('https://chat.wrmgpt.com/register', { waitUntil: 'networkidle2' });
|
| 64 |
-
await
|
| 65 |
|
| 66 |
await page.type('input[id="email"]', email);
|
| 67 |
await page.type('input[id="password"]', password);
|
| 68 |
await page.type('input[id="confirmPassword"]', password);
|
| 69 |
|
| 70 |
await page.click('button[type="submit"]');
|
| 71 |
-
await
|
| 72 |
|
| 73 |
await browser.close();
|
| 74 |
return 'Registration completed';
|
|
@@ -79,7 +84,7 @@ class WormGPTScraper {
|
|
| 79 |
const maxAttempts = 10;
|
| 80 |
|
| 81 |
while (attempts < maxAttempts) {
|
| 82 |
-
await
|
| 83 |
|
| 84 |
try {
|
| 85 |
const response = await axios.get(`${this.tempMailAPI}/email/${email}/messages`, {
|
|
@@ -111,7 +116,7 @@ class WormGPTScraper {
|
|
| 111 |
const page = await browser.newPage();
|
| 112 |
|
| 113 |
await page.goto(verificationUrl, { waitUntil: 'networkidle2' });
|
| 114 |
-
await
|
| 115 |
|
| 116 |
await browser.close();
|
| 117 |
return 'Email verified';
|
|
@@ -126,13 +131,13 @@ class WormGPTScraper {
|
|
| 126 |
const page = await browser.newPage();
|
| 127 |
|
| 128 |
await page.goto('https://chat.wrmgpt.com/login', { waitUntil: 'networkidle2', timeout: 30000 });
|
| 129 |
-
await
|
| 130 |
|
| 131 |
await page.type('input[id="email"]', email);
|
| 132 |
await page.type('input[id="password"]', password);
|
| 133 |
|
| 134 |
await page.click('button[type="submit"]');
|
| 135 |
-
await
|
| 136 |
|
| 137 |
const currentUrl = page.url();
|
| 138 |
const isLoggedIn = currentUrl.includes('chat.wrmgpt.com') && !currentUrl.includes('login');
|
|
@@ -258,7 +263,7 @@ class WormGPTScraper {
|
|
| 258 |
});
|
| 259 |
}
|
| 260 |
|
| 261 |
-
await
|
| 262 |
}
|
| 263 |
|
| 264 |
return {
|
|
@@ -287,7 +292,7 @@ class WormGPTScraper {
|
|
| 287 |
|
| 288 |
await this.verifyEmail(verificationUrl);
|
| 289 |
|
| 290 |
-
await
|
| 291 |
|
| 292 |
const loginResult = await this.loginAndGetSession(email, password);
|
| 293 |
|
|
@@ -323,7 +328,7 @@ class WormGPTScraper {
|
|
| 323 |
} catch (error) {
|
| 324 |
return {
|
| 325 |
success: false,
|
| 326 |
-
|
| 327 |
stack: error.stack,
|
| 328 |
step: 'error'
|
| 329 |
};
|
|
|
|
| 16 |
this.currentChatId = null;
|
| 17 |
}
|
| 18 |
|
| 19 |
+
// Helper function untuk mengganti waitForTimeout
|
| 20 |
+
async delay(ms) {
|
| 21 |
+
return new Promise(resolve => setTimeout(resolve, ms));
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
generatePassword(length = 12) {
|
| 25 |
const uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
| 26 |
const lowercase = 'abcdefghijklmnopqrstuvwxyz';
|
|
|
|
| 66 |
const page = await browser.newPage();
|
| 67 |
|
| 68 |
await page.goto('https://chat.wrmgpt.com/register', { waitUntil: 'networkidle2' });
|
| 69 |
+
await this.delay(2000);
|
| 70 |
|
| 71 |
await page.type('input[id="email"]', email);
|
| 72 |
await page.type('input[id="password"]', password);
|
| 73 |
await page.type('input[id="confirmPassword"]', password);
|
| 74 |
|
| 75 |
await page.click('button[type="submit"]');
|
| 76 |
+
await this.delay(3000);
|
| 77 |
|
| 78 |
await browser.close();
|
| 79 |
return 'Registration completed';
|
|
|
|
| 84 |
const maxAttempts = 10;
|
| 85 |
|
| 86 |
while (attempts < maxAttempts) {
|
| 87 |
+
await this.delay(3000);
|
| 88 |
|
| 89 |
try {
|
| 90 |
const response = await axios.get(`${this.tempMailAPI}/email/${email}/messages`, {
|
|
|
|
| 116 |
const page = await browser.newPage();
|
| 117 |
|
| 118 |
await page.goto(verificationUrl, { waitUntil: 'networkidle2' });
|
| 119 |
+
await this.delay(5000);
|
| 120 |
|
| 121 |
await browser.close();
|
| 122 |
return 'Email verified';
|
|
|
|
| 131 |
const page = await browser.newPage();
|
| 132 |
|
| 133 |
await page.goto('https://chat.wrmgpt.com/login', { waitUntil: 'networkidle2', timeout: 30000 });
|
| 134 |
+
await this.delay(3000);
|
| 135 |
|
| 136 |
await page.type('input[id="email"]', email);
|
| 137 |
await page.type('input[id="password"]', password);
|
| 138 |
|
| 139 |
await page.click('button[type="submit"]');
|
| 140 |
+
await this.delay(15000);
|
| 141 |
|
| 142 |
const currentUrl = page.url();
|
| 143 |
const isLoggedIn = currentUrl.includes('chat.wrmgpt.com') && !currentUrl.includes('login');
|
|
|
|
| 263 |
});
|
| 264 |
}
|
| 265 |
|
| 266 |
+
await this.delay(1000);
|
| 267 |
}
|
| 268 |
|
| 269 |
return {
|
|
|
|
| 292 |
|
| 293 |
await this.verifyEmail(verificationUrl);
|
| 294 |
|
| 295 |
+
await this.delay(5000);
|
| 296 |
|
| 297 |
const loginResult = await this.loginAndGetSession(email, password);
|
| 298 |
|
|
|
|
| 328 |
} catch (error) {
|
| 329 |
return {
|
| 330 |
success: false,
|
| 331 |
+
error: error.message,
|
| 332 |
stack: error.stack,
|
| 333 |
step: 'error'
|
| 334 |
};
|