Spaces:
Paused
Paused
Mohammed Foud
commited on
Commit
·
df99bb4
1
Parent(s):
4e1fb8f
all
Browse files- login-check-failed.png +3 -0
- login-check.png +3 -0
- login_failed.png +2 -2
- page.html +0 -0
- src/webook/login.ts +15 -5
- src/webook/main.ts +1 -1
- src/webook/webookBase.ts +10 -2
login-check-failed.png
ADDED
|
Git LFS Details
|
login-check.png
ADDED
|
Git LFS Details
|
login_failed.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
page.html
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
src/webook/login.ts
CHANGED
|
@@ -64,17 +64,23 @@ export class WeBookLogin extends WeBookBase {
|
|
| 64 |
if (!this.page) throw new Error('Page not initialized');
|
| 65 |
try {
|
| 66 |
|
| 67 |
-
|
|
|
|
|
|
|
| 68 |
const content = await this.page.content();
|
| 69 |
-
await
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
// Wait only for the profile button to appear, timeout after 5 seconds
|
| 73 |
const userProfileButton = await this.page.locator('button[aria-haspopup="dialog"]');
|
| 74 |
-
|
| 75 |
|
| 76 |
console.info('User profile button found, clicking to open dropdown...');
|
| 77 |
await userProfileButton.click();
|
|
|
|
| 78 |
|
| 79 |
// Wait a short time for the dropdown dialog to render
|
| 80 |
await this.page.waitForTimeout(1000);
|
|
@@ -104,7 +110,11 @@ export class WeBookLogin extends WeBookBase {
|
|
| 104 |
}
|
| 105 |
console.info('Not logged in, proceeding with login form');
|
| 106 |
// await this.handleCookies();
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
await this.submitLoginForm();
|
| 109 |
if (await this.checkLoginResult()) {
|
| 110 |
return this.page;
|
|
|
|
| 64 |
if (!this.page) throw new Error('Page not initialized');
|
| 65 |
try {
|
| 66 |
|
| 67 |
+
// this.page.goto('https://webook.com/en');
|
| 68 |
+
await this.page.goto('https://webook.com/en', { waitUntil: 'networkidle' });
|
| 69 |
+
await this.handleCookies();
|
| 70 |
const content = await this.page.content();
|
| 71 |
+
await this.page.screenshot({ path: 'login-check-failed.png', fullPage: true });
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
// await fs.writeFile('page.html', content);
|
| 75 |
+
// console.info('Dumping page content to page.html');
|
| 76 |
|
| 77 |
// Wait only for the profile button to appear, timeout after 5 seconds
|
| 78 |
const userProfileButton = await this.page.locator('button[aria-haspopup="dialog"]');
|
| 79 |
+
await userProfileButton.waitFor({ timeout: 5000 });
|
| 80 |
|
| 81 |
console.info('User profile button found, clicking to open dropdown...');
|
| 82 |
await userProfileButton.click();
|
| 83 |
+
|
| 84 |
|
| 85 |
// Wait a short time for the dropdown dialog to render
|
| 86 |
await this.page.waitForTimeout(1000);
|
|
|
|
| 110 |
}
|
| 111 |
console.info('Not logged in, proceeding with login form');
|
| 112 |
// await this.handleCookies();
|
| 113 |
+
this.page.goto('https://webook.com/en/login');
|
| 114 |
+
|
| 115 |
+
// this.page.goto('https://webook.com/en/login');
|
| 116 |
+
await this.page.screenshot({ path: 'login-check.png', fullPage: true });
|
| 117 |
+
|
| 118 |
await this.submitLoginForm();
|
| 119 |
if (await this.checkLoginResult()) {
|
| 120 |
return this.page;
|
src/webook/main.ts
CHANGED
|
@@ -6,7 +6,7 @@ export async function main() {
|
|
| 6 |
const password = '009988Ppooii@@@@'; // Replace with your password
|
| 7 |
const eventUrl = 'https://webook.com/en/events/mdlbeast-beast-house-ec/book'//'https://webook.com/en/events/ewc-opening-ceremony-2025-tickets/book'; // Replace with your event URL
|
| 8 |
|
| 9 |
-
const login = new WeBookLogin(email, password);
|
| 10 |
const page = await login.login();
|
| 11 |
if (!page) {
|
| 12 |
console.error('Login failed. Exiting.');
|
|
|
|
| 6 |
const password = '009988Ppooii@@@@'; // Replace with your password
|
| 7 |
const eventUrl = 'https://webook.com/en/events/mdlbeast-beast-house-ec/book'//'https://webook.com/en/events/ewc-opening-ceremony-2025-tickets/book'; // Replace with your event URL
|
| 8 |
|
| 9 |
+
const login = new WeBookLogin(email, password, 'rr');
|
| 10 |
const page = await login.login();
|
| 11 |
if (!page) {
|
| 12 |
console.error('Login failed. Exiting.');
|
src/webook/webookBase.ts
CHANGED
|
@@ -42,15 +42,23 @@ export class WeBookBase {
|
|
| 42 |
this.browser = await chromium.launchPersistentContext(this.profileDir, {
|
| 43 |
headless: headless,
|
| 44 |
args: ['--disable-blink-features=AutomationControlled'],
|
| 45 |
-
|
| 46 |
-
viewport: { width: 1920, height: 1080 },
|
| 47 |
});
|
| 48 |
this.page = this.browser.pages()[0] || await this.browser.newPage();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
this.browser.setDefaultTimeout(60_000);
|
| 50 |
this.page.setDefaultNavigationTimeout(60_000);
|
| 51 |
|
| 52 |
console.info(`Using profile directory: ${this.profileDir}`);
|
| 53 |
console.info(`Playwright headless mode: ${headless}`);
|
|
|
|
| 54 |
}
|
| 55 |
return { context: this.browser, page: this.page };
|
| 56 |
}
|
|
|
|
| 42 |
this.browser = await chromium.launchPersistentContext(this.profileDir, {
|
| 43 |
headless: headless,
|
| 44 |
args: ['--disable-blink-features=AutomationControlled'],
|
| 45 |
+
// viewport: { width: 1920, height: 1080 },
|
|
|
|
| 46 |
});
|
| 47 |
this.page = this.browser.pages()[0] || await this.browser.newPage();
|
| 48 |
+
|
| 49 |
+
// @ts-ignore
|
| 50 |
+
const userAgent = await this.page.evaluate(() => navigator.userAgent);
|
| 51 |
+
const cleanUserAgent = userAgent.replace('HeadlessChrome', 'Chrome');
|
| 52 |
+
|
| 53 |
+
await this.page.setExtraHTTPHeaders({
|
| 54 |
+
'User-Agent': cleanUserAgent
|
| 55 |
+
});
|
| 56 |
this.browser.setDefaultTimeout(60_000);
|
| 57 |
this.page.setDefaultNavigationTimeout(60_000);
|
| 58 |
|
| 59 |
console.info(`Using profile directory: ${this.profileDir}`);
|
| 60 |
console.info(`Playwright headless mode: ${headless}`);
|
| 61 |
+
console.info(`Using User-Agent: ${cleanUserAgent}`);
|
| 62 |
}
|
| 63 |
return { context: this.browser, page: this.page };
|
| 64 |
}
|