Blog>
Snippets

Automating Job Search with Puppeteer

Showcase how to automate job application processes on multiple platforms using Puppeteer to increase the chances of breaking salary stagnation by landing new job offers.
const puppeteer = require('puppeteer');

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

  // Navigate to job platform
  await page.goto('https://www.example-job-platform.com', { waitUntil: 'networkidle2' });

  // Log in to the platform
  await page.type('#login-field', 'your_username');
  await page.type('#password-field', 'your_password');
  await page.click('#login-button');

  // Wait for navigation after login
  await page.waitForNavigation({ waitUntil: 'networkidle0' });

  // Go to the job search section
  await page.click('#job-search-link');
  await page.waitForSelector('#job-listings');

  // Loop through available jobs
  const jobListings = await page.$$('#job-listings > .job');
  for (const jobElement of jobListings) {
    const title = await jobElement.$eval('.job-title', el => el.innerText);
    console.log(`Applying to job: ${title}`);
    // You would add actions here to apply to each job
  }

  // Close the browser when done
  await browser.close();
})();
This Puppeteer script automates logging into a job platform, navigating to the job search section, and iterating through job listings. You should replace selectors and URLs with those corresponding to the actual platform you're targeting. Additionally, include the logic for applying to a job within the loop.
<!-- HTML skeleton for login page (to be served by job platform) -->
<!DOCTYPE html>
<html lang='en'>
<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Login</title>
    <link rel='stylesheet' href='styles.css'>
</head>
<body>
    <div id='login-container'>
        <input type='text' id='login-field' placeholder='Username'>
        <input type='password' id='password-field' placeholder='Password'>
        <button id='login-button'>Login</button>
    </div>
</body>
</html>
This is a sample HTML markup representing the login page of a job platform. It includes input fields for the username and password, and a login button, which the Puppeteer script would interact with.
/* CSS for the login page */
#login-container {
  display: flex;
  flex-direction: column;
  width: 300px;
  margin: 100px auto;
}
#login-field, #password-field {
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
}
#login-button {
  padding: 10px 20px;
  border: none;
  background-color: #007bff;
  color: white;
  border-radius: 5px;
  cursor: pointer;
}
The accompanying CSS styles for the login page. These styles define the login container, input fields, and button layout.