Skip to content

Instantly share code, notes, and snippets.

@dragoscv
Created August 24, 2023 23:04
Show Gist options
  • Save dragoscv/a1e6c64660df7196c6f1191bdf56415f to your computer and use it in GitHub Desktop.
Save dragoscv/a1e6c64660df7196c6f1191bdf56415f to your computer and use it in GitHub Desktop.
Crawler nxp node js puppeteer
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch(
// {
// headless: false,
// defaultViewport: null,
// args: ['--start-maximized']
// }
);
const page = await browser.newPage();
await page.goto('https://nxp.wd3.myworkdayjobs.com/careers?Location_Country=f2e609fe92974a55a05fc1cdc2852122');
const listingsElement = await page.waitForSelector('#mainContent > div > div.css-uvpbop > section > ul');
const listings = await listingsElement.$$eval('li', anchors => {
return anchors.map(anchor => {
const titleElement = anchor.querySelector('h3');
const locationElement = anchor.querySelector('div');
const linkElement = anchor.querySelector('a');
const title = titleElement ? titleElement.textContent : '';
const location = locationElement ? locationElement.textContent : '';
const link = linkElement ? linkElement.href : '';
return { title, location, link };
});
});
const data = await page.content();
console.log(listings);
await browser.close();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment