saitejatirunagari's picture
feat: integrate ever-jobs for 170 job platforms, content fingerprint dedup, grouped UI selector
b617fcc
Raw
History Blame
1.51 kB
from src.scrapers.base import Job
def map_job(j: dict) -> Job:
loc = j.get("location") or {}
if isinstance(loc, dict):
city = loc.get("city", "") or ""
state = loc.get("state", "") or ""
country = loc.get("country", "") or ""
location_str = ", ".join(filter(None, [city, state, country])) or "Remote"
else:
location_str = str(loc) if loc else "Remote"
comp = j.get("compensation") or {}
salary_str = "Not specified"
if comp.get("minAmount"):
currency = comp.get("currency", "")
amount = comp["minAmount"]
interval = comp.get("interval", "yearly")
max_amt = comp.get("maxAmount")
if max_amt and max_amt != amount:
salary_str = f"{currency}{amount:,}{max_amt:,}/{interval}"
else:
salary_str = f"{currency}{amount:,}/{interval}"
url = (
j.get("jobUrl") or
j.get("job_url") or
j.get("jobPostingUrl") or
""
)
company = j.get("companyName") or j.get("company_name") or j.get("company") or ""
date = j.get("datePosted") or j.get("date_posted") or ""
job_id = str(j.get("id") or "")
platform = j.get("site") or "ever-jobs"
return Job(
title=j.get("title", ""),
company=company,
location=location_str,
url=url,
platform=platform,
description=j.get("description", ""),
salary=salary_str,
posted_date=date,
job_id=job_id,
)