Update FirstEnergy scraper login flow

This commit is contained in:
Deep Koluguri 2026-06-28 15:19:55 -04:00
parent c848385ebb
commit a250e2d88e
1 changed files with 15 additions and 5 deletions

View File

@ -22,15 +22,25 @@ async function runScrapers(credentials) {
try { try {
await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36'); await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36');
await page.goto('https://www.firstenergycorp.com/log_in.html', { waitUntil: 'networkidle2' }); await page.goto('https://www.firstenergycorp.com/content/customer/log_in.html', { waitUntil: 'networkidle2' });
await page.waitForSelector('input[name="USER"], input[name="username"], #username', { timeout: 15000 }); // Wait for the login button to appear and click it, which triggers the B2C redirect
await page.type('input[name="USER"], input[name="username"], #username', credentials.firstEnergy.username); await page.waitForSelector('a[href*="b2clogin.firstenergycorp.com"]', { timeout: 10000 }).catch(()=>null);
await page.type('input[name="PASSWORD"], input[name="password"], #password', credentials.firstEnergy.password); await page.evaluate(() => {
const loginBtn = document.querySelector('a[href*="b2clogin.firstenergycorp.com"]');
if (loginBtn) loginBtn.click();
});
// Wait for navigation to the B2C login page
await page.waitForNavigation({ waitUntil: 'networkidle0', timeout: 15000 }).catch(()=>null);
await page.waitForSelector('#signInName, input[name="signInName"]', { timeout: 15000 });
await page.type('#signInName, input[name="signInName"]', credentials.firstEnergy.username);
await page.type('#password, input[name="password"]', credentials.firstEnergy.password);
await Promise.all([ await Promise.all([
page.waitForNavigation({ waitUntil: 'networkidle2' }), page.waitForNavigation({ waitUntil: 'networkidle2' }),
page.click('button[type="submit"], input[type="submit"]') page.click('#next, button[type="submit"]')
]); ]);
console.log('[Scraper] Logged into FirstEnergy. Extracting usage...'); console.log('[Scraper] Logged into FirstEnergy. Extracting usage...');