Ashby, BambooHR, Deel, Eightfold, Gem, Greenhouse, HiBob, HR Manager, Jibe, Jobylon and Lever move to feed_url(slug, ask) and page(get, slug, cursor, ask), declare READS with the robots decision, and drop robots_page. Rows carry places (Ashby secondaryLocations, Lever allLocations, Greenhouse offices in place of a Hybrid placeholder), Jobylon keeps its summary as teaser and maps experience and employment, Eightfold reads creationTs as the posting date and Ashby reads workplaceType. Fixtures <name>-places.* and jobylon-teaser.html drive the conformance checks; the eleven names leave UNDECLARED. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
174 lines
6.6 KiB
Python
174 lines
6.6 KiB
Python
"""BambooHR: `bamboohr:<subdomain>` for acme.bamboohr.com, the whole board in
|
|
one JSON answer and each role's text, date and country on its own page.
|
|
|
|
Written from Configit's board on 2026-09-29 (two roles); jobhunt-hq did not
|
|
read BambooHR. Unverified: whether a large board pages `/careers/list` (this
|
|
one states `meta.totalCount` and no paging keys, so a list shorter than its
|
|
count is refused rather than read as the whole board), and the words of
|
|
`locationType`, taken to be BambooHR's own settings, "0" in the office, "1"
|
|
remote and "2" hybrid; Configit's hybrid roles say "2" and `isRemote` is null.
|
|
|
|
A posting that invites an unsolicited application without a role (Configit's
|
|
first) is listed like any other role.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import html
|
|
import json
|
|
import logging
|
|
import re
|
|
from collections.abc import Callable
|
|
from typing import Any
|
|
|
|
from desk.sources import strip_html
|
|
|
|
from ._contract import Ask, Fields, Place, Reads, Row
|
|
from ._shared import Get, label_slug_ok, only, parse_dt
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
READS = Reads(
|
|
scope="board", listing="whole", text="detail", complete="whole",
|
|
places="one",
|
|
fields=Fields(posted="trusted", remote="stated", employment="stated"),
|
|
robots="read: robots.txt allows /careers (checked 2026-09-29)",
|
|
)
|
|
|
|
#: `employmentStatusLabel` -> the app's employment words. BambooHR's labels are
|
|
#: the company's own ("Full-Time", "Part-Time", "Contract", "Intern").
|
|
_EMPLOYMENT = {"full-time": "full_time", "full time": "full_time", "part-time": "part_time",
|
|
"part time": "part_time", "contract": "contract", "contractor": "contract",
|
|
"temporary": "temporary", "intern": "intern", "internship": "intern",
|
|
"freelance": "freelance"}
|
|
|
|
NAME = "bamboohr"
|
|
LABEL = "BambooHR"
|
|
PATTERNS = (
|
|
# Not the company's own app or documentation subdomains, which BambooHR
|
|
# itself serves and which name no board.
|
|
r"https?://(?!(?:app|resources|documentation|help)\.)([a-z0-9-]+)\.bamboohr\.com",
|
|
)
|
|
|
|
#: `locationType` -> `store._remote`'s words. Anything else says nothing.
|
|
_REMOTE = {"0": "onsite", "1": "remote", "2": "hybrid"}
|
|
|
|
#: Sent on the detail read: without it the same URL answers the page's HTML.
|
|
_JSON = {"Accept": "application/json"}
|
|
|
|
|
|
def host(slug: str) -> str:
|
|
return f"{slug.lower()}.bamboohr.com"
|
|
|
|
|
|
def slug_ok(slug: str) -> bool:
|
|
return label_slug_ok(slug)
|
|
|
|
|
|
def allowed(slug: str) -> Callable[[str], bool]:
|
|
return only(host(slug))
|
|
|
|
|
|
def careers_url(slug: str) -> str:
|
|
return f"https://{host(slug)}/careers"
|
|
|
|
|
|
def feed_url(slug: str, ask: Ask) -> str:
|
|
return f"https://{host(slug)}/careers/list"
|
|
|
|
|
|
def _remote(j: dict[str, Any]) -> str | None:
|
|
if j.get("isRemote") is True:
|
|
return "remote"
|
|
return _REMOTE.get(str(j.get("locationType") if j.get("locationType") is not None else ""))
|
|
|
|
|
|
def _place(j: dict[str, Any]) -> str:
|
|
"""City, state and country of a role, as far as either of its two
|
|
location objects states them (`atsLocation` mirrors `location` and is
|
|
filled by companies that use BambooHR's own applicant tracking)."""
|
|
place, ats_place = j.get("location") or {}, j.get("atsLocation") or {}
|
|
country = place.get("addressCountry") or ats_place.get("country")
|
|
parts = (place.get("city") or ats_place.get("city"),
|
|
place.get("state") or ats_place.get("state"), country)
|
|
return ", ".join(str(p).strip() for p in parts if p and str(p).strip())
|
|
|
|
|
|
def _places(j: dict[str, Any]) -> list[Place]:
|
|
"""The one place BambooHR states, if it states any."""
|
|
text = _place(j)
|
|
return [{"text": text, "remote": True if re.search(r"\bremote\b", text, re.I) else None}] \
|
|
if text else []
|
|
|
|
|
|
def _employment(j: dict[str, Any]) -> str | None:
|
|
label = str(j.get("employmentStatusLabel") or "").strip()
|
|
if not label:
|
|
return None
|
|
found = _EMPLOYMENT.get(label.lower())
|
|
if found is None:
|
|
log.debug("bamboohr: unknown employmentStatusLabel %r", label)
|
|
return found
|
|
|
|
|
|
def parse(body: bytes, slug: str) -> list[Row]:
|
|
"""`/careers/list` -> `{"meta": {"totalCount": n}, "result": [...]}`. A
|
|
role has `id`, `jobOpeningName`, `departmentLabel`, `location` (`city`,
|
|
`state`), `atsLocation` (the same with a `country`, null so far),
|
|
`isRemote` and `locationType`. The text, the date and the country are only
|
|
on the role's own page (`detail`), which is why `description` and `posted`
|
|
are empty here."""
|
|
data = json.loads(body)
|
|
listed = data.get("result") if isinstance(data, dict) else None
|
|
if not isinstance(listed, list):
|
|
raise ValueError("not a BambooHR listing: no result list")
|
|
stated = (data.get("meta") or {}).get("totalCount")
|
|
if isinstance(stated, int) and stated > len(listed):
|
|
raise ValueError(f"BambooHR listing has {len(listed)} of {stated} roles")
|
|
out = []
|
|
for j in listed:
|
|
title = (j.get("jobOpeningName") or "").strip()
|
|
source_id = str(j.get("id") or "")
|
|
if not title or not source_id:
|
|
continue
|
|
places = _places(j)
|
|
row: Row = {
|
|
"source_id": source_id,
|
|
"title": title,
|
|
"places": places,
|
|
"location": _place(j),
|
|
"url": f"https://{host(slug)}/careers/{source_id}",
|
|
"posted": None,
|
|
"department": str(j.get("departmentLabel") or "").strip(),
|
|
"description": "",
|
|
"remote": _remote(j),
|
|
"salary_text": "", # the list states no pay; the detail's `compensation` was null
|
|
}
|
|
if employment := _employment(j):
|
|
row["employment"] = employment
|
|
out.append(row)
|
|
return out
|
|
|
|
|
|
def detail(get: Get, slug: str, row: Row) -> dict[str, Any]:
|
|
"""`/careers/<id>/detail` -> `{"result": {"jobOpening": {...}}}`, with the
|
|
HTML `description`, `datePosted` (a date), `location` (`city`, `state`,
|
|
`addressCountry`) and `locationType`. The location is the listing's with
|
|
the country added, since the listing has none."""
|
|
data = json.loads(get(f"https://{host(slug)}/careers/{row['source_id']}/detail",
|
|
headers=_JSON))
|
|
opening = ((data.get("result") or {}).get("jobOpening")
|
|
if isinstance(data, dict) else None)
|
|
if not isinstance(opening, dict):
|
|
raise ValueError("not a BambooHR role: no result.jobOpening")
|
|
out: dict[str, Any] = {
|
|
"description": " ".join(html.unescape(strip_html(opening.get("description") or "")).split()),
|
|
"posted": parse_dt(opening.get("datePosted")),
|
|
}
|
|
if place := _place(opening):
|
|
out["location"] = place
|
|
out["places"] = _places(opening)
|
|
if remote := _remote(opening):
|
|
out["remote"] = remote
|
|
return out
|