Skip to content

Repository files navigation

LinkedIn Saved Jobs Extractor

A Playwright script that extracts LinkedIn saved jobs from the past 30 days using cookies from an existing Chrome browser and saves them to your Obsidian vault with dataview integration.

Features

  • Uses your existing Chrome login cookies (no password required)
  • Extracts all saved jobs from LinkedIn
  • Filters jobs by date saved (default: last 30 days)
  • Exports to multiple formats:
    • JSON: Complete structured data
    • CSV: Tabular format for spreadsheet analysis
    • Markdown: Human-readable format
  • Obsidian integration:
    • Saves jobs directly to your Obsidian vault
    • Adds YAML frontmatter for dataview plugin integration
    • Prevents duplicate job entries in your vault
    • Formats filenames for Obsidian compatibility
  • CLI support for easy on-demand execution
  • Automated daily extraction via cron

Prerequisites

  • Node.js 16+ installed
  • Google Chrome with active LinkedIn session
  • macOS (default cookie path is set for macOS; see Configuration for other platforms)
  • Optional: Obsidian with the Dataview plugin for enhanced job tracking

Installation

  1. Clone or download this repository
  2. Navigate to the project directory
  3. Install dependencies:
npm install

This will install:

  • playwright: For browser automation
  • sqlite3 and sqlite: For reading Chrome cookies
  • commander: For CLI functionality

Configuration

Before running, you may want to adjust settings in config.js:

module.exports = {
  // Chrome cookie settings
  chromeProfilePath: '~/Library/Application Support/Google/Chrome/Default', // MacOS default path
  // Alternative Chrome profiles (uncomment if needed)
  // chromeProfilePath: '~/Library/Application Support/Google/Chrome/Profile 1', // Chrome Profile 1
  // chromeProfilePath: '~/Library/Application Support/Google/Chrome', // Chrome root dir (searches all profiles)
  
  // Browser settings
  headless: false, // Set to true to run browser in headless mode
  slowMo: 500, // Slow down browser actions in non-headless mode (ms)
  
  // Job extraction settings
  daysThreshold: 30, // Only extract jobs saved within the last X days
  filterDuplicates: true, // Remove duplicate job entries
  filterOptions: {
    keywords: [], // Filter jobs by these keywords (title or description)
    companies: [], // Filter jobs from these companies
    locations: [], // Filter jobs in these locations
    excludeKeywords: [] // Exclude jobs with these keywords
  },
  
  // Output settings
  outputPath: './output', // Directory to save extracted job data
  obsidianPath: '/Users/yourname/Obsidian/vault/Jobs', // Path to Obsidian vault Jobs directory
  saveToObsidian: true, // Save jobs to Obsidian vault
  outputFormats: ['json', 'csv', 'markdown'], // Available formats: json, csv, markdown, html
  
  // LinkedIn credentials (optional fallback)
  linkedinCredentials: {
    username: 'your-email@example.com', // Your LinkedIn email/username
    password: 'your-password'  // Your LinkedIn password
  },
  
  // Retry settings
  maxRetries: 3,
  retryDelay: 1000 // ms
};

Environment Variables

All configuration options can also be set using environment variables:

# Chrome and browser settings
export LINKEDIN_CHROME_PROFILE="~/Library/Application Support/Google/Chrome/Default"
export LINKEDIN_HEADLESS="true"
export LINKEDIN_SLOW_MO="500"

# Job extraction settings
export LINKEDIN_DAYS_THRESHOLD="30"

# Output settings
export LINKEDIN_OUTPUT_PATH="./output"
export LINKEDIN_OBSIDIAN_PATH="/path/to/obsidian/vault/Jobs"
export LINKEDIN_SAVE_TO_OBSIDIAN="true"
export LINKEDIN_OUTPUT_FORMATS="json,csv,markdown"

# LinkedIn credentials (optional)
export LINKEDIN_USERNAME="your-email@example.com"
export LINKEDIN_PASSWORD="your-password"

# Retry settings
export LINKEDIN_MAX_RETRIES="3"
export LINKEDIN_RETRY_DELAY="1000"

Environment variables take precedence over settings in the config.js file, making it easy to override settings for specific runs or in CI/CD environments.

Platform-specific cookie paths

  • macOS: ~/Library/Application Support/Google/Chrome/Default
  • Windows: %LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default
  • Linux: ~/.config/google-chrome/Default

For Chrome profiles other than "Default", adjust the path accordingly.

Usage

Basic Usage

You can run the script in several ways:

# Basic execution
npm start

# Using the CLI
npm run extract

# Using the CLI with options
node cli.js extract --days 14 --headless

# Directly from CLI if globally installed
linkedin-jobs extract --days 14 --headless

The script will:

  1. Extract cookies from your Chrome browser
  2. Launch a Playwright browser instance
  3. Authenticate with LinkedIn using your cookies (or credentials if cookies fail)
  4. Navigate to your saved jobs
  5. Extract job details for each saved job (within the date threshold)
  6. Save the extracted jobs to the specified output formats
  7. Save the jobs to your Obsidian vault with proper frontmatter for dataview

Extracted jobs will be saved to:

  • The output directory (as JSON, CSV, and Markdown)
  • Your Obsidian vault's Jobs directory (as individual Markdown files with frontmatter)

CLI Commands and Options

The CLI tool provides several commands and options for managing the extraction:

Usage: linkedin-jobs [command] [options]

Commands:
  extract   Extract saved jobs from LinkedIn
  status    Check the status of the last extraction run
  update    Check for updates to the LinkedIn Saved Jobs Extractor
  config    Show or update configuration

Extract command options:
  -d, --days <number>     Number of days to look back for saved jobs (default: 30)
  -o, --output <path>     Output directory for extracted jobs (default: ./output)
  --obsidian <path>       Obsidian vault path for job files
  --no-obsidian           Disable saving to Obsidian vault
  --profile <path>        Chrome profile path for cookies
  --headless              Run browser in headless mode
  --formats <formats>     Output formats (comma-separated) (default: json,csv,markdown)

Update command options:
  --check-only            Only check for updates without updating

Config command options:
  -l, --list              List current configuration
  -e, --edit              Open configuration file in default editor

Global options:
  -h, --help              Display help for command
  -V, --version           Display version number

Command Examples

# Extract jobs from the last 14 days
linkedin-jobs extract --days 14

# Extract jobs with custom output formats
linkedin-jobs extract --formats json,markdown

# Check the status of the last extraction run
linkedin-jobs status

# Check for updates
linkedin-jobs update --check-only

# Apply available updates
linkedin-jobs update

# View current configuration
linkedin-jobs config --list

# Edit configuration file
linkedin-jobs config --edit

Automated Daily Execution

To set up automated daily execution:

  1. Make the script executable:

    chmod +x setup-cron.sh
  2. Run the setup script:

    ./setup-cron.sh
  3. Follow the prompts to:

    • Set the time for daily execution
    • Configure email notifications (optional)

The script will set up a cron job to run the LinkedIn Jobs Extractor daily at your specified time. Logs will be saved to the logs directory.

Email Notifications

The script supports email notifications for:

  • Successful extractions
  • Failed extractions
  • When new jobs are found

To configure email notifications:

  1. During the setup-cron.sh script, answer "y" when asked about email notifications
  2. Provide your email address and select notification preferences
  3. Make sure the mail command is available on your system:
    • macOS: brew install mailutils
    • Ubuntu/Debian: sudo apt-get install mailutils
    • CentOS/RHEL: sudo yum install mailx

Alternatively, you can manually edit the .extract_config file to adjust notification settings after setup.

Obsidian Integration

The script integrates with the Dataview plugin for Obsidian, allowing you to:

  • Filter and query your saved jobs using dataview queries
  • Build job application dashboards
  • Track your application status for each job
  • Sort and filter jobs by company, location, date posted, etc.

The job files include YAML frontmatter with fields like:

---
title: "Job Title"
company: "Company Name"
location: "Location (Remote/Hybrid/On-site)"
date_posted: "YYYY-MM-DD"
date_extracted: "YYYY-MM-DD" 
url: "LinkedIn Job URL"
status: "To Apply"
---

You can update the status field manually to track your progress:

  • "To Apply"
  • "Applied"
  • "Interview Scheduled"
  • "Rejected"
  • "Offer Received"

How It Works

  1. Cookie Extraction: The script extracts LinkedIn cookies from your Chrome browser's cookie database. It can search in multiple profiles if configured to do so.
  2. Authentication: These cookies are added to a Playwright browser context to authenticate with LinkedIn, with fallback to credential-based login if needed.
  3. Job Extraction: The script navigates to your saved jobs page and extracts basic information for each job listing.
  4. Detailed Extraction: For each job, the script visits the job listing page to get complete details.
  5. Data Export: The extracted job data is saved in the standard formats (JSON, CSV, Markdown).
  6. Obsidian Export: Jobs are also saved to your Obsidian vault with proper frontmatter for dataview integration, ensuring no duplicates are created.

Troubleshooting

Authentication Issues

  • Make sure you are logged into LinkedIn in your Chrome browser
  • Check that the Chrome profile path in config.js matches your system
  • If using a non-default Chrome profile, adjust the path accordingly
  • Try running with headless: false to see what's happening
  • Add your LinkedIn credentials in config.js as a fallback

Job Extraction Issues

  • LinkedIn occasionally changes its UI, which may break selectors
  • Check for console errors when running the script
  • If job listings aren't found, try adjusting the selectors in jobScraper.js

Cookie Issues

  • Make sure Chrome is closed before running the script (to avoid cookie database lock)
  • If Chrome is encrypting cookies with your system password, try logging into LinkedIn in an incognito window first

Cron Job Issues

  • Check the logs in the logs directory for error messages
  • Make sure the paths in the cron job are absolute paths
  • Ensure cron has permission to access the required directories

Limitations

  • LinkedIn may detect automated access and temporarily limit your account
  • LinkedIn UI changes may require updating the selectors used
  • The script currently only works with Chrome; other browsers are not supported
  • Very large numbers of saved jobs may take time to process

License

MIT

About

A tool to extract LinkedIn saved jobs using cookies from Chrome browser

Resources

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages