modif
This commit is contained in:
parent
8f8e3bd585
commit
fa8cebdef5
5 changed files with 24 additions and 9 deletions
|
|
@ -104,35 +104,47 @@ const scrapeLinkedInProfile = async (profileUrl, email, password) => {
|
||||||
try {
|
try {
|
||||||
// === 1. Login ===
|
// === 1. Login ===
|
||||||
await page.goto("https://www.linkedin.com/login", {
|
await page.goto("https://www.linkedin.com/login", {
|
||||||
waitUntil: "networkidle",
|
waitUntil: "domcontentloaded",
|
||||||
timeout: 60000,
|
timeout: 60000,
|
||||||
});
|
});
|
||||||
console.log("Login page loaded");
|
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("#username", email, { delay: 50 });
|
||||||
await page.fill("#password", password, { delay: 50 });
|
await page.fill("#password", password, { delay: 50 });
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
page.click('[type="submit"]'),
|
page.click('[type="submit"]'),
|
||||||
page.waitForNavigation({ waitUntil: "networkidle", timeout: 60000 }),
|
page.waitForNavigation({ waitUntil: "domcontentloaded", timeout: 60000 }),
|
||||||
]);
|
]);
|
||||||
console.log("Logged in");
|
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 ===
|
// === 2. Aller sur le profil ===
|
||||||
await page.goto(profileUrl, {
|
await page.goto(profileUrl, {
|
||||||
waitUntil: "networkidle",
|
waitUntil: "domcontentloaded",
|
||||||
timeout: 60000,
|
timeout: 60000,
|
||||||
});
|
});
|
||||||
await page.waitForSelector("h1", { timeout: 60000 });
|
await page.waitForSelector("h1", { timeout: 60000 });
|
||||||
console.log("Profile page loaded");
|
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
|
// Scroll pour charger contenu lazy
|
||||||
await page.evaluate(() => window.scrollBy(0, window.innerHeight));
|
await page.evaluate(() => window.scrollBy(0, window.innerHeight));
|
||||||
await page.waitForTimeout(2000);
|
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 ===
|
// === 3. Extraire les infos ===
|
||||||
const profileData = await page.evaluate(() => {
|
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);
|
console.log("Data extracted:", profileData);
|
||||||
|
|
||||||
|
|
@ -164,7 +179,7 @@ const scrapeLinkedInProfile = async (profileUrl, email, password) => {
|
||||||
return profileData;
|
return profileData;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("❌ Erreur pendant le scraping:", err.message);
|
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();
|
await browser.close();
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
error.png
BIN
error.png
Binary file not shown.
|
Before Width: | Height: | Size: 45 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 45 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 45 KiB |
BIN
step1_login.png
BIN
step1_login.png
Binary file not shown.
|
Before Width: | Height: | Size: 45 KiB |
Loading…
Add table
Reference in a new issue