File size: 970 Bytes
b55c84b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({ headless: true });
  const page = await browser.newPage();

  // Navigate to a URL
  await page.goto('https://www.linkedin.com/in/iamyashchouhan/');
  
  // Wait for the content to load
  await page.waitForSelector('h1.text-heading-xlarge');
  
  // Extract data
  const name = await page.$eval('h1.text-heading-xlarge', el => el.innerText);
  const jobTitle = await page.$eval('div.text-body-medium.break-words', el => el.innerText);
  const companyName = await page.$eval('span.text-body-small.t-black', el => el.innerText);
  const location = await page.$eval('span.text-body-small.inline.t-black--light.break-words', el => el.innerText);
  const profilePicture = await page.$eval('img.pv-top-card-profile-picture__image', el => el.src);

  console.log({
    name,
    jobTitle,
    companyName,
    location,
    profilePicture,
  });

  await browser.close();
})();