Giter Club home page Giter Club logo

indeed-jobs-searcher's Introduction

indeed-jobs-searcher

Simple CLI-based tool for extracting and storing relevant job info. from bulk job searches on indeed.com.

This project was originally based on Sidharth's Indeed scraper (explained here: https://www.pycodemates.com/2022/01/Indeed-jobs-scraping-with-python-bs4-selenium-and-pandas.html). Running Sidharth's code showed me a workable proof of concept (after tweaking the code) for extracting and storing useful job information from Indeed, using Selenium and BeautifulSoup. It has since required changes due to updates of the Selenium package and changes in the structure of Indeed's HTML.

I originally developed this program to help me find a job for when I finished my Master's degree. I'm now happily employed, but I'll share a bit about how this project fit into my larger personal project: I used my data analytics skills to compile a list of top cities where I wished to live and work (based on several factors: different measures of diversity, cost of living, proximity to friends and family, etc.). Part of my analysis was figuring out which of my prospective cities had the jobs I was looking for. Hence this project was born. I derived a CSV file of cities by printing out a DataFrame from my analysis and then I plugged the CSV file into my jobs searcher to capture available jobs for each location into an Excel workbook which I imported with pandas for the next phase in my analysis.

Showcase screenshots of the command-line interface and the results

  • Upgraded packages from Python 3.11.5 to Python 3.12.4.
  • Updated scraper module to adapt to LinkedIn's HTML format changes (the company div class name changed).
  • Updated fileio module to use the xlsxwriter engine when exporting dataframes (openpyxl is a pain).

My examples use the command python3 which is specific to Linux. If you are using Windows, simply use python instead.

  • Device with Internet access and Google Chrome web browser installed (AND UPDATED)
  • Python 3.12.4 or newer on device

For this project, we want to first set up a virtual environment. This way, we can install dependencies to this virtual environment rather than our global Python environment. This will allows us to isolate our dependencies.

1. First, open your terminal to the main folder of this cloned repository and make sure you have the virtualenv package installed:

pip install --user virtualenv

In Ubuntu-based distributions, you can install it using:

sudo apt install python3-venv

  1. Create the virtualenv (still in the main repo folder):

python3 -m venv venv

  1. Activate it.

3a. In PowerShell:

\venv\Scripts\activate

3b. In Linux:

source venv/bin/activate

To deactivate it (when you want to use your user Python environment), simply type deactivate.

  1. Install the requirements.

pip install -r requirements.txt

(You will have to use pip3 in Linux)

For bulk searching, you will need to feed in a CSV file of your locations. The CSV file format has been simplified:

  1. The first column from the left must contain a location name.
  2. The second column from the left may be used to specify a more general region (e.g., state, providence) or it may be left blank.

Refer to the following image as a reference:

Screenshot of an example CSV location file

Refer to the help menu depicted below by running python3 jobsearch.py -h.

Usage (help):              jobsearch.py -h, jobsearch.py --help

Usage (single search):     jobsearch.py -l "<location name>" [options]
  Options:
    -f, --file <file name> Custom file name (can include path).
    -q, --query <query>    The job search query.
    -u, --url <Indeed URL> Tailor URL to country (defaults to USA).
    -s, --save <boolean>   True if unspecified. False if false value is given.

Usage (batch search):      jobsearch.py -c <locations CSV file> [options]
  Options:
    -f, --file <file name> Custom file name (can include path).
    -q, --query <query>    The job search query.
    -u, --url <Indeed URL> Tailor URL to country (defaults to USA).
    -s, --save <boolean>   True if unspecified. False if false value is given.
    --startindex <int>     0-based row index in CSV file to start from (inclusive).
    --stopindex  <int>     0-based row index in CSV file to stop after (inclusive).

Examples (single search):
  jobsearch.py -l "Johnson City, TN" -q "('software engineer' OR 'software developer')"
  jobsearch.py -l "Tokyo" -u https://jp.indeed.com -q "software engineer"
  jobsearch.py -l "Tokyo" -u https://jp.indeed.com -f "C:\Users\User\Desktop\ty-job-search"
  jobsearch.py -l "Tokyo" -u https://jp.indeed.com -f /home/user/Desktop/ty-job-search
  jobsearch.py -l "Bengaluru" -u https://in.indeed.com --save false

Examples (batch search):
  jobsearch.py -c locations/southeast-cities.csv -q "('software engineer' OR 'software developer')"
  jobsearch.py -c locations/southeast-cities.csv -f "C:\Users\User\Desktop\SE-jobs-search"
  jobsearch.py -c locations/southeast-cities.csv -f /home/user/Desktop/SE-jobs-search
  jobsearch.py -c locations/indian-cities.csv -u https://in.indeed.com
  jobsearch.py -c locations/southeast-cities.csv --startindex 10
  jobsearch.py -c locations/southeast-cities.csv --stopindex 10
  jobsearch.py -c locations/southeast-cities.csv --startindex 10 --stopindex 20

Locations CSV file format
  Each row can have one or two locations (e.g. city or city, region) but no more.
  The left column should specify the city. The right column should specify the region/province/state.

  The first row may be used as the column names.

  Example file format:
    City        State
    Birmingham  AL
    Richmond    KY
    Georgetown  KY

Saved Files
  If no file path is specificied (using the -f argument)
  the resulting files are saved in the searched_jobs folder.

If no file path is specificied (using the -f argument) the resulting files are saved in the searched_jobs folder.

Assume we execute the script as such:

python3 jobsearch.py -c ./locations/southeast-cities.csv --startindex 1 --stopindex 3

Next we enter our job query. You can use Boolean logic if you'd like:

Enter your query >>"mechanical" and "engineer" and not "electrical"

The indexing is zero-based (as a programmer, it's the only way for me!). What that means is that the second, third, and fourth locations in the file will be searched (the stopindex is inclusive):

locations/southeast-cities.csv

City         State
Raleigh      NC  <-- Index 0
Nashville    TN  <-- Index 1 (start here)
Norfolk      VA
Hampton      VA  <-- Index 3 (stop after scraping for this location)
Murfreesboro TN
. . .

The results are stored in the searched_jobs folder (unless a custom path was used in the file argument. The first part of each default file name (before the underscore) is a timestamp of when the data was scraped.

The scraped job-search data are stored in the Excel workbook with bulk-job-searches.xlsx in its name. Each sheet in the workbook features the results for each location searched from the locations CSV file.

Screenshot of scraped job search data in an Excel worksheet

The locations searched, the entered job query, and the resulting URLs from which the results were scraped are stored in the Excel workbook with bulk-urls-searched.xlsx in its name.

Screenshot of locations searched, entered job query, and the resulting URLs in an Excel worksheet

A single search produces a similar Excel workbook file but for convenience, the worksheet also has a URL column listing the URL of the page from which the program scraped its results. The workbook name will end with single-job-search.

NOTE: When you perform a single search, if your location is more than one word, it is important that you enclose your query in quotation marks, e.g.,

python3 jobsearch.py -l "Johnson City, TN"
python3 jobsearch.py -l "Chicago, IL" -q "('software engineer' OR 'software developer')"

indeed-jobs-searcher's People

Contributors

alimovlex avatar haasr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

indeed-jobs-searcher's Issues

Only pulling first page of results

It seems that only the first page of results is appearing in the export (~14 jobs). Is there a way to pull all results for a given search?

Selenium fails with inability to look for the XPath element.

Hello!
Here is the script crash log that I got after running the request with --save false parameter

> Commencing single search...
Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="text-input-what"]"}
  (Session info: chrome-headless-shell=126.0.6478.126); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Stacktrace:
#0 0x55850fc73c7a <unknown>
#1 0x55850f956e2c <unknown>
#2 0x55850f9a3661 <unknown>
#3 0x55850f9a3751 <unknown>
#4 0x55850f9e7f64 <unknown>
#5 0x55850f9c65ed <unknown>
#6 0x55850f9e5303 <unknown>
#7 0x55850f9c6363 <unknown>
#8 0x55850f996247 <unknown>
#9 0x55850f996b9e <unknown>
#10 0x55850fc3a24b <unknown>
#11 0x55850fc3e2f1 <unknown>
#12 0x55850fc25afe <unknown>
#13 0x55850fc3ee52 <unknown>
#14 0x55850fc0a79f <unknown>
#15 0x55850fc63638 <unknown>
#16 0x55850fc63810 <unknown>
#17 0x55850fc72dac <unknown>
#18 0x7f78d2120962 start_thread


URL searched:
https://nl.indeed.com
Search results:
None

But the xpath variables work in the following script:
https://github.com/stesiakethan/indeed_scraper/blob/main/scraper_main.py

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.