diff --git a/controllers/linkedin.js b/controllers/linkedin.js index 560678f..816bcfa 100644 --- a/controllers/linkedin.js +++ b/controllers/linkedin.js @@ -91,7 +91,11 @@ const getUserProfile = async (req, res) => { } }; -const scrapeLinkedInProfile = async (profileUrl) => { +const scrapeLinkedInProfile = async (user) => { + const img = user.img; + const useremail = user.email; + const profileUrl = user.linkedinUrl; + console.log("Scraping LinkedIn profile:", profileUrl); const browser = await chromium.launch({ @@ -156,16 +160,19 @@ const scrapeLinkedInProfile = async (profileUrl) => { ); return { - img: getText("img.pv-top-card-profile-picture__image--show"), + img: user.img || null, + email: user.email || null, + linkedinUrl: user.linkedinUrl || null, + name: getText("h1"), headline: getText("div.text-body-medium.break-words"), location: getText( "span.text-body-small.inline.t-black--light.break-words" ), // about: getText(""), - // experiences: getAllText( - // "" - // ), + experiences: getAllText( + "div.KbuWagYZEALUPOYGtkFczhgTiHHNRLZKhdLlK > ul li" + ), // education: getAllText(""), // skills: getAllText(""), }; diff --git a/routes/front.routes.js b/routes/front.routes.js index 89bae80..1db5ff7 100644 --- a/routes/front.routes.js +++ b/routes/front.routes.js @@ -44,7 +44,7 @@ router.get("/me", async (req, res) => { `); } - const profile = await scrapeLinkedInProfile(user.linkedinUrl); + const profile = await scrapeLinkedInProfile(user); res.send(profile); });