Skip to content

Commit

Permalink
enh: estimated salary
Browse files Browse the repository at this point in the history
  • Loading branch information
cullenwatson committed Jul 17, 2024
1 parent d8d33d6 commit 23f6b4a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "python-jobspy"
version = "1.1.58"
version = "1.1.59"
description = "Job scraper for LinkedIn, Indeed, Glassdoor & ZipRecruiter"
authors = ["Zachary Hampton <[email protected]>", "Cullen Watson <[email protected]>"]
homepage = "https://github.com/Bunsly/JobSpy"
Expand Down
31 changes: 26 additions & 5 deletions src/jobspy/scrapers/indeed/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def _process_job(self, job: dict) -> JobPost | None:
country=job.get("location", {}).get("countryCode"),
),
job_type=job_type,
compensation=self._get_compensation(job),
compensation=self._get_compensation(job["compensation"]),
date_posted=date_posted,
job_url=job_url,
job_url_direct=(
Expand Down Expand Up @@ -281,14 +281,19 @@ def _get_job_type(attributes: list) -> list[JobType]:
return job_types

@staticmethod
def _get_compensation(job: dict) -> Compensation | None:
def _get_compensation(compensation: dict) -> Compensation | None:
"""
Parses the job to get compensation
:param job:
:param job:
:return: compensation object
"""
comp = job["compensation"]["baseSalary"]
if not compensation["baseSalary"] and not compensation["estimated"]:
return None
comp = (
compensation["baseSalary"]
if compensation["baseSalary"]
else compensation["estimated"]["baseSalary"]
)
if not comp:
return None
interval = IndeedScraper._get_compensation_interval(comp["unitOfWork"])
Expand All @@ -300,7 +305,11 @@ def _get_compensation(job: dict) -> Compensation | None:
interval=interval,
min_amount=int(min_range) if min_range is not None else None,
max_amount=int(max_range) if max_range is not None else None,
currency=job["compensation"]["currencyCode"],
currency=(
compensation["estimated"]["currencyCode"]
if compensation["estimated"]
else compensation["currencyCode"]
),
)

@staticmethod
Expand Down Expand Up @@ -388,6 +397,18 @@ def _get_compensation_interval(interval: str) -> CompensationInterval:
}}
}}
compensation {{
estimated {{
currencyCode
baseSalary {{
unitOfWork
range {{
... on Range {{
min
max
}}
}}
}}
}}
baseSalary {{
unitOfWork
range {{
Expand Down

0 comments on commit 23f6b4a

Please sign in to comment.