Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const puppeteer = require('puppeteer');
|
2 |
+
|
3 |
+
(async () => {
|
4 |
+
const browser = await puppeteer.launch({ headless: true });
|
5 |
+
const page = await browser.newPage();
|
6 |
+
|
7 |
+
// Navigate to a URL
|
8 |
+
await page.goto('https://www.linkedin.com/in/iamyashchouhan/');
|
9 |
+
|
10 |
+
// Wait for the content to load
|
11 |
+
await page.waitForSelector('h1.text-heading-xlarge');
|
12 |
+
|
13 |
+
// Extract data
|
14 |
+
const name = await page.$eval('h1.text-heading-xlarge', el => el.innerText);
|
15 |
+
const jobTitle = await page.$eval('div.text-body-medium.break-words', el => el.innerText);
|
16 |
+
const companyName = await page.$eval('span.text-body-small.t-black', el => el.innerText);
|
17 |
+
const location = await page.$eval('span.text-body-small.inline.t-black--light.break-words', el => el.innerText);
|
18 |
+
const profilePicture = await page.$eval('img.pv-top-card-profile-picture__image', el => el.src);
|
19 |
+
|
20 |
+
console.log({
|
21 |
+
name,
|
22 |
+
jobTitle,
|
23 |
+
companyName,
|
24 |
+
location,
|
25 |
+
profilePicture,
|
26 |
+
});
|
27 |
+
|
28 |
+
await browser.close();
|
29 |
+
})();
|