91 lines
3.0 KiB
Python
91 lines
3.0 KiB
Python
"""SmartRecruiters: `smartrecruiters:<company identifier>`, paged by offset
|
|
with a stated total. The identifier is case-sensitive (`BoschGroup`).
|
|
|
|
Written from one real board on 2026-09-23; jobhunt-hq did not read
|
|
SmartRecruiters.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from collections.abc import Callable
|
|
from typing import Any
|
|
|
|
from ._shared import Get, Page, Row, only, parse_dt, path_slug_ok
|
|
|
|
NAME = "smartrecruiters"
|
|
LABEL = "SmartRecruiters"
|
|
RANK = 50
|
|
PATTERNS = (
|
|
r"(?:jobs|careers|api)\.smartrecruiters\.com/(?:v1/companies/)?([A-Za-z0-9_-]+)",
|
|
)
|
|
|
|
_API = "api.smartrecruiters.com"
|
|
|
|
#: The page size asked for, which is also the most the host serves per page.
|
|
PAGE_SIZE = 100
|
|
|
|
|
|
def slug_ok(slug: str) -> bool:
|
|
return path_slug_ok(slug)
|
|
|
|
|
|
def allowed(slug: str) -> Callable[[str], bool]:
|
|
return only(_API)
|
|
|
|
|
|
def careers_url(slug: str) -> str:
|
|
return f"https://jobs.smartrecruiters.com/{slug}"
|
|
|
|
|
|
def probe_url(slug: str) -> str:
|
|
return f"https://{_API}/v1/companies/{slug}/postings?limit=1"
|
|
|
|
|
|
def probe_ok(body: bytes) -> bool:
|
|
"""An unknown identifier answers an empty listing, so a listing without
|
|
postings counts as no board."""
|
|
return b'"totalFound":' in body and b'"totalFound":0' not in body
|
|
|
|
|
|
def page(get: Get, slug: str, cursor: Any) -> Page:
|
|
offset = int(cursor or 0)
|
|
data = json.loads(get(f"https://{_API}/v1/companies/{slug}/postings"
|
|
f"?offset={offset}&limit={PAGE_SIZE}"))
|
|
content = data.get("content") or []
|
|
return data, content, data.get("totalFound"), offset + len(content) if content else None
|
|
|
|
|
|
def parse(body: bytes, slug: str) -> list[Row]:
|
|
return rows(json.loads(body), slug)
|
|
|
|
|
|
def rows(data: dict[str, Any], slug: str) -> list[Row]:
|
|
"""One page of https://api.smartrecruiters.com/v1/companies/{slug}/postings
|
|
-> `{"offset", "limit", "totalFound", "content": [...]}`. At most 100 a
|
|
page, whatever `limit` asks for; the next is `?offset=` further on. The
|
|
list omits the job description (only the per-posting detail endpoint has
|
|
it, and fetching one per row would be hundreds of extra requests per
|
|
board), so `description` stays empty here."""
|
|
out = []
|
|
for j in data.get("content") or []:
|
|
title = (j.get("name") or "").strip()
|
|
job_id = str(j.get("id") or "")
|
|
if not title or not job_id:
|
|
continue
|
|
location = j.get("location") or {}
|
|
loc_text = (location.get("fullLocation")
|
|
or ", ".join(p for p in (location.get("city"), location.get("country")) if p))
|
|
out.append({
|
|
"source_id": job_id,
|
|
"title": title,
|
|
"location": (loc_text or "").strip(),
|
|
"url": f"https://jobs.smartrecruiters.com/{slug}/{job_id}",
|
|
"posted": parse_dt(j.get("releasedDate")),
|
|
"department": ((j.get("department") or {}).get("label") or "").strip(),
|
|
"description": "",
|
|
"remote": location.get("remote"),
|
|
"salary_text": "", # SmartRecruiters' list endpoint states no pay at all
|
|
})
|
|
return out
|