JobSpy/README.md

202 lines
7.0 KiB
Markdown
Raw Normal View History

2023-08-26 12:41:33 -07:00
# JobSpy AIO Scraper
2023-07-10 20:14:38 -07:00
## Features
2023-08-26 12:41:33 -07:00
- Scrapes job postings from **LinkedIn**, **Indeed** & **ZipRecruiter** simultaneously
2023-08-27 14:59:47 -07:00
- Returns jobs as JSON or CSV with title, location, company, description & other data
2023-08-27 18:32:46 -07:00
- Imports directly into **Google Sheets**
2023-08-26 12:41:33 -07:00
- Optional JWT authorization
2023-08-19 18:41:46 -07:00
2023-08-27 18:32:46 -07:00
![jobspy_gsheet](https://github.com/cullenwatson/JobSpy/assets/78247585/9f0a997c-4e33-4167-b04e-31ab1f606edb)
2023-08-19 16:44:16 -07:00
2023-08-26 12:41:33 -07:00
### API
2023-08-19 16:44:16 -07:00
2023-08-26 12:41:33 -07:00
POST `/api/v1/jobs/`
### Request Schema
2023-08-26 18:30:00 -07:00
2023-08-27 14:52:27 -07:00
```plaintex
Required
├── site_type (List[enum]): linkedin, zip_recruiter, indeed
└── search_term (str)
Optional
├── location (int)
├── distance (int)
├── job_type (enum): fulltime, parttime, internship, contract
├── is_remote (bool)
├── results_wanted (int): per site_type
├── easy_apply (bool): only for linkedin
2023-08-27 18:32:46 -07:00
└── output_format (enum): json, csv, gsheet
2023-08-26 18:30:00 -07:00
```
### Request Example
```json
2023-08-27 14:52:27 -07:00
"site_type": ["indeed", "linkedin"],
"search_term": "software engineer",
"location": "austin, tx",
"distance": 10,
"job_type": "fulltime",
"results_wanted": 15
2023-08-27 18:32:46 -07:00
"output_format": "gsheet"
```
2023-08-19 16:44:16 -07:00
### Response Schema
2023-08-26 18:30:00 -07:00
```plaintext
2023-08-27 14:52:27 -07:00
site_type (enum):
JobResponse
├── success (bool)
├── error (str)
├── jobs (List[JobPost])
│ └── JobPost
│ ├── title (str)
│ ├── company_name (str)
│ ├── job_url (str)
│ ├── location (object)
│ │ ├── country (str)
│ │ ├── city (str)
│ │ ├── state (str)
│ ├── description (str)
│ ├── job_type (enum)
│ ├── compensation (object)
│ │ ├── interval (CompensationInterval): yearly, monthly, weekly, daily, hourly
│ │ ├── min_amount (float)
│ │ ├── max_amount (float)
│ │ └── currency (str)
│ └── date_posted (datetime)
├── total_results (int)
└── returned_results (int)
2023-08-26 18:30:00 -07:00
```
2023-08-27 18:32:46 -07:00
### Response Example (GOOGLE SHEETS)
```json
{
"status": "Successfully uploaded to Google Sheets",
"error": null,
"linkedin": null,
"indeed": null,
"zip_recruiter": null
}
```
2023-08-27 14:25:48 -07:00
### Response Example (JSON)
```json
{
2023-08-26 18:30:00 -07:00
"indeed": {
"success": true,
"error": null,
"jobs": [
{
"title": "Software Engineer",
"company_name": "INTEL",
"job_url": "https://www.indeed.com/jobs/viewjob?jk=a2cfbb98d2002228",
"location": {
"country": "USA",
2023-08-26 18:30:00 -07:00
"city": "Austin",
"state": "TX",
},
"description": "Job Description Designs, develops, tests, and debugs..."
2023-08-26 18:30:00 -07:00
"job_type": "fulltime",
"compensation": {
"interval": "yearly",
"min_amount": 209760.0,
"max_amount": 139480.0,
"currency": "USD"
},
"date_posted": "2023-08-18T00:00:00"
}, ...
],
"total_results": 845,
"returned_results": 15
},
"linkedin": {
2023-08-26 18:30:00 -07:00
"success": true,
"error": null,
"jobs": [
{
"title": "Software Engineer 1",
"company_name": "Public Partnerships | PPL",
"job_url": "https://www.linkedin.com/jobs/view/3690013792",
2023-08-26 18:30:00 -07:00
"location": {
"country": "USA",
2023-08-26 18:30:00 -07:00
"city": "Austin",
"state": "TX",
},
"description": "Public Partnerships LLC supports individuals with disabilities..."
"job_type": null,
"compensation": null,
"date_posted": "2023-07-31T00:00:00"
}, ...
2023-08-26 18:30:00 -07:00
],
"total_results": 2000,
"returned_results": 15
2023-08-26 18:30:00 -07:00
}
}
```
2023-08-27 14:25:48 -07:00
### Response Example (CSV)
```
Site, Title, Company Name, Job URL, Country, City, State, Job Type, Compensation Interval, Min Amount, Max Amount, Currency, Date Posted, Description
indeed, Software Engineer, INTEL, https://www.indeed.com/jobs/viewjob?jk=a2cfbb98d2002228, USA, Austin, TX, fulltime, yearly, 209760.0, 139480.0, USD, 2023-08-18T00:00:00, Job Description Designs...
linkedin, Software Engineer 1, Public Partnerships | PPL, https://www.linkedin.com/jobs/view/3690013792, USA, Austin, TX, , , , , , 2023-07-31T00:00:00, Public Partnerships LLC supports...
```
2023-08-23 15:52:36 -07:00
2023-07-10 20:14:38 -07:00
## Installation
2023-08-27 14:52:27 -07:00
_Python version >= [3.10](https://www.python.org/downloads/release/python-3100/) required_
2023-08-26 12:41:33 -07:00
1. Clone this repository `git clone https://github.com/cullenwatson/jobspy`
2023-08-17 13:46:03 -07:00
2. Install the dependencies with `pip install -r requirements.txt`
2023-08-19 16:44:16 -07:00
4. Run the server with `uvicorn main:app --reload`
2023-07-10 20:14:38 -07:00
## Usage
2023-08-27 18:32:46 -07:00
### Google Sheets Integration (Optional)
2023-07-10 20:14:38 -07:00
2023-08-27 18:32:46 -07:00
#### Obtaining an Access Key : [Video Guide](https://www.youtube.com/watch?v=w533wJuilao)
* Enable the [Google Sheets & Google Drive API](https://console.cloud.google.com/)
* Create credentials -> service account -> create & continue
* Select role -> basic: editor -> done
* Click on the email you just created in the service account list
* Go to the Keys tab -> add key -> create new key -> JSON -> Create
2023-08-27 18:32:46 -07:00
#### Using the key in the repo
* Copy the key file into the JobSpy repo as `/client_secret.json`
* Go to [my template sheet](https://docs.google.com/spreadsheets/d/1HAnn-aPv-BO4QTEzfIWc-5iw50duyMoTgX8o3RsEOWs/edit?usp=sharing) & save as a copy into your account
* Share the sheet with the email from the service account above with editor rights
* If you changed the name of the sheet, put the name in `GSHEET_NAME` in `/settings.py`
### How to call the API
#### [Postman](https://www.postman.com/downloads/) (preferred):
To use Postman:
1. Locate the files in the `/postman/` directory.
2. Import the Postman collection and environment JSON files.
2023-08-19 16:44:16 -07:00
2023-08-27 18:32:46 -07:00
#### Swagger UI:
Or you can call the API with the interactive documentation at [localhost:8000/docs](http://localhost:8000/docs).
2023-08-19 16:44:16 -07:00
## FAQ
2023-08-19 18:37:49 -07:00
### I'm having issues with my queries. What should I do?
2023-08-19 16:44:16 -07:00
2023-08-27 14:52:27 -07:00
Try reducing the number of `results_wanted` and/or broadening the filters. If issues still persist, feel free to submit an issue.
### I'm getting response code 429. What should I do?
You have been blocked by the job board site for sending too many requests. Wait a couple seconds or use a VPN.
2023-08-19 16:44:16 -07:00
2023-08-19 18:37:49 -07:00
### How to enable auth?
2023-08-19 16:44:16 -07:00
2023-08-19 18:37:49 -07:00
Change `AUTH_REQUIRED` in `/settings.py` to `True`
2023-07-10 20:14:38 -07:00
2023-08-19 18:45:53 -07:00
The auth uses [supabase](https://supabase.com). Create a project with a `users` table and disable RLS.
2023-08-19 18:47:05 -07:00
<img src="https://github.com/cullenwatson/jobspy/assets/78247585/03af18e1-5386-49ad-a2cf-d34232d9d747" width="500">
2023-08-19 18:45:53 -07:00
2023-08-19 18:37:49 -07:00
Add these three environment variables:
- `SUPABASE_URL`: go to project settings -> API -> Project URL
- `SUPABASE_KEY`: go to project settings -> API -> service_role secret
- `JWT_SECRET_KEY` - type `openssl rand -hex 32` in terminal to create a 32 byte secret key
2023-08-26 12:41:33 -07:00
Use these endpoints to register and get an access token:
![image](https://github.com/cullenwatson/jobspy/assets/78247585/c84c33ec-1fe8-4152-9c8c-6c4334aecfc3)