Mohammed Foud commited on
Commit
df99bb4
·
1 Parent(s): 4e1fb8f
login-check-failed.png ADDED

Git LFS Details

  • SHA256: dd04bc8f43b7b0b8e3efc772bb7f03c5f116d41c38682dbd48b97922b80d0609
  • Pointer size: 132 Bytes
  • Size of remote file: 3.38 MB
login-check.png ADDED

Git LFS Details

  • SHA256: 7735d290d098f00cfebb25f4e0842e127cef4c855ec1be779a08321b76466de8
  • Pointer size: 129 Bytes
  • Size of remote file: 4.33 kB
login_failed.png CHANGED

Git LFS Details

  • SHA256: 129aad02821be62e6b479e5022b11d898adabf73968cc6767ca380ec4dc7386d
  • Pointer size: 131 Bytes
  • Size of remote file: 494 kB

Git LFS Details

  • SHA256: 8a22d52d7b21aa6e8236ea20f6e21f6700d97f1c7eeb6fa085094161f8561d0c
  • Pointer size: 130 Bytes
  • Size of remote file: 29.9 kB
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
- await this.page.goto('https://webook.com/en');
 
 
68
  const content = await this.page.content();
69
- await fs.writeFile('page.html', content);
70
- console.info('Dumping page content to page.html');
 
 
 
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
- // await userProfileButton.waitFor({ timeout: 5000 });
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
- this.page.goto('https://webook.com/en/login');
 
 
 
 
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
- userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36',
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
  }