diff --git a/controllers/linkedin.js b/controllers/linkedin.js index 07bcf5f..2aa2412 100644 --- a/controllers/linkedin.js +++ b/controllers/linkedin.js @@ -104,35 +104,47 @@ const scrapeLinkedInProfile = async (profileUrl, email, password) => { try { // === 1. Login === await page.goto("https://www.linkedin.com/login", { - waitUntil: "networkidle", + waitUntil: "domcontentloaded", timeout: 60000, }); console.log("Login page loaded"); - await page.screenshot({ path: "step1_login.png", fullPage: true }); + await page.screenshot({ + path: "public/error/step1_login.png", + fullPage: true, + }); await page.fill("#username", email, { delay: 50 }); await page.fill("#password", password, { delay: 50 }); await Promise.all([ page.click('[type="submit"]'), - page.waitForNavigation({ waitUntil: "networkidle", timeout: 60000 }), + page.waitForNavigation({ waitUntil: "domcontentloaded", timeout: 60000 }), ]); console.log("Logged in"); - await page.screenshot({ path: "step2_logged_in.png", fullPage: true }); + await page.screenshot({ + path: "public/error/step2_logged_in.png", + fullPage: true, + }); // === 2. Aller sur le profil === await page.goto(profileUrl, { - waitUntil: "networkidle", + waitUntil: "domcontentloaded", timeout: 60000, }); await page.waitForSelector("h1", { timeout: 60000 }); console.log("Profile page loaded"); - await page.screenshot({ path: "step3_profile_loaded.png", fullPage: true }); + await page.screenshot({ + path: "public/error/step3_profile_loaded.png", + fullPage: true, + }); // Scroll pour charger contenu lazy await page.evaluate(() => window.scrollBy(0, window.innerHeight)); await page.waitForTimeout(2000); - await page.screenshot({ path: "step4_scrolled.png", fullPage: true }); + await page.screenshot({ + path: "public/error/step4_scrolled.png", + fullPage: true, + }); // === 3. Extraire les infos === const profileData = await page.evaluate(() => { @@ -156,7 +168,10 @@ const scrapeLinkedInProfile = async (profileUrl, email, password) => { }; }); - await page.screenshot({ path: "step5_data_extracted.png", fullPage: true }); + await page.screenshot({ + path: "public/error/step5_data_extracted.png", + fullPage: true, + }); console.log("Data extracted:", profileData); @@ -164,7 +179,7 @@ const scrapeLinkedInProfile = async (profileUrl, email, password) => { return profileData; } catch (err) { console.error("❌ Erreur pendant le scraping:", err.message); - await page.screenshot({ path: "error.png", fullPage: true }); + await page.screenshot({ path: "public/error/error.png", fullPage: true }); await browser.close(); throw err; } diff --git a/error.png b/error.png deleted file mode 100644 index fe63ecf..0000000 Binary files a/error.png and /dev/null differ diff --git a/public/img/error.png b/public/img/error.png deleted file mode 100644 index fe63ecf..0000000 Binary files a/public/img/error.png and /dev/null differ diff --git a/public/img/step1_login.png b/public/img/step1_login.png deleted file mode 100644 index fe63ecf..0000000 Binary files a/public/img/step1_login.png and /dev/null differ diff --git a/step1_login.png b/step1_login.png deleted file mode 100644 index fe63ecf..0000000 Binary files a/step1_login.png and /dev/null differ