<aside> 🔗 https://github.com/AdamManuel-dev/LinkedInNotifications

</aside>

In the fast-paced world of job hunting, staying ahead of the competition means being the first to know about new opportunities. With the power of automation, you can have a system that scrapes LinkedIn for job postings and notifies you in real-time. This blog post dives into a JavaScript script using Puppeteer, Node-Notifier, and Node-Cron to make your job search more efficient.

Setting the Stage: The Components

The script integrates several key components:

  1. Puppeteer: A Node library that provides a high-level API to control Chrome or Chromium over the DevTools Protocol. It allows us to navigate the web programmatically.
  2. Node-Notifier: A Node.js module for sending notifications on native systems (Windows, Mac, Linux).
  3. Node-Cron: A task scheduler in pure JavaScript for running scheduled jobs.
  4. CSV File: Stores the job search configurations.
  5. Cache File: Maintains a log of previously seen job postings to avoid duplicate notifications.

Step-by-Step Breakdown

1. Reading Configurations

The script begins by reading configurations from a CSV file, searches.csv, which contains search terms, intervals, and LinkedIn URLs:

javascriptCopy code
const configCSV = fs.readFileSync('./searches.csv', {
  encoding: 'utf-8',
})

const configArr = configCSV.split('\n').map((line) => line.split(','));

configArr.shift()

const input = configArr.filter((x) => x.length === 3).map(([title, minuteLapse, url]) => ({
  url,
  title,
  minuteLapse: Number.parseInt(minuteLapse)
}))

This code reads the CSV file, splits it into lines, and maps each line to an object containing the job title, time interval, and LinkedIn search URL.

2. Caching Previous Job Postings

To avoid notifying about the same job postings multiple times, the script reads a cache file that stores previously seen URLs:

javascriptCopy code
const _cachedUrls = fs.readFileSync('./cache', {
  encoding: 'utf-8',
})

const cachedUrls = ((_cachedUrls.includes('\n')) ? _cachedUrls.split('\n') : []).filter((x) => x.length !== 0)

3. Scraping LinkedIn

The main function grabLinks uses Puppeteer to navigate to LinkedIn search pages, scrape job posting links, and filter out those already seen: