"""Jibe (iCIMS Jibe): `jibe:`, the career site's own host name, for example `jibe:jobs.booking.com`. A JSON API on that host, paged by page number at 100 roles a page, with the total stated. Written from Booking.com's site on 2026-09-29 (145 roles, two pages), the only Jibe site read. Unverified: that another Jibe site serves `/api/jobs` with the same parameters and answer, and what one that does not gives. A host that is not a Jibe site fails as a board that is not a listing. `GET /api/jobs?limit=100&page=N` answers `{"jobs": [{"data": {...}}], "totalCount"}` with each role's full description, so the roles need no `detail`; `limit=200` is a 422. The findings used `brand=Booking.com`, which is not needed: without it the site's whole board is read, 145 roles, of which the filter keeps the 97 of brand "Booking.com" and drops the 48 of brand "Booking Holdings", the parent's own roles (finance, legal and data teams in Bucharest, listed and applied for on the same site). The board is read whole, as the site shows it, and `brand` is not in the target. A role's page is `/jobs/` on the host, which redirects to the site's own path (`/booking/jobs/` on Booking's), so no site's path prefix is built in. The site's robots.txt asks for `crawl-delay: 5`, which the shared reader does not honour (`ats.PAGE_DELAY` is 0.5 s); a board is two requests. Discovery can name Jibe (a site loads its assets from `jibecdn.com` or applies on `jibeapply.com`) but not the host, since a Jibe site's own links look like any other site's, so the host is given by hand. """ from __future__ import annotations import json import logging import re from collections.abc import Callable from typing import Any from ._contract import Ask, Fields, Place, Reads, Row from ._shared import Get, Page, add_place, html_text, only, parse_dt, place log = logging.getLogger(__name__) READS = Reads( scope="board", listing="paged", page_size=100, text="listing", complete="stated", places="many", fields=Fields(posted="listed", country="stated", employment="stated"), robots=("read: robots.txt allows /, so /api/jobs, with crawl-delay 5 not honoured " "(jobs.booking.com, checked 2026-09-30)"), ) NAME = "jibe" LABEL = "Jibe" PATTERNS = ( # No slug: the host is the company's own, which no URL on the page names. r"jibeapply\.com|jibecdn\.com/prod", ) #: The page size asked for, which is also the most the host serves (200 is a 422). PAGE_SIZE = 100 #: A whole host name (two labels or more, the last one letters), so neither an #: address (`127.0.0.1`), a bare word (`localhost`) nor a port names a site. #: `ats._get` refuses every host but this one, redirects included, and a local #: name or an address in any case. _HOST = re.compile(r"[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*\.[a-z]{2,}") #: Names a private network uses, never a company's career site; `ats._get` #: refuses them too, and a slug that names one is not a board at all. _LOCAL = (".localhost", ".local", ".internal", ".lan", ".home.arpa") def slug_ok(slug: str) -> bool: host = slug.lower() return bool(_HOST.fullmatch(host)) and not host.endswith(_LOCAL) def allowed(slug: str) -> Callable[[str], bool]: return only(slug) def careers_url(slug: str) -> str: return f"https://{slug.lower()}/jobs" def page(get: Get, slug: str, cursor: Any, ask: Ask) -> Page: """One page of `/api/jobs`; the next is the following number, and an empty page ends the read.""" number = int(cursor or 1) data = json.loads(get(f"https://{slug.lower()}/api/jobs?limit={PAGE_SIZE}&page={number}")) jobs = data.get("jobs") if isinstance(data, dict) else None if not isinstance(jobs, list): raise ValueError("not a Jibe listing: no jobs list") total = data.get("totalCount") results = [{"id": (j.get("data") or {}).get("slug") or ""} for j in jobs] return data, results, total if isinstance(total, int) else None, \ number + 1 if jobs else None def parse(body: bytes, slug: str) -> list[Row]: return rows(json.loads(body), slug) def _places(j: dict[str, Any]) -> list[Place]: """`full_location` names every place of the role, "; " apart, each as "City, Country"; the site's `city` and `country` stand in when it is missing.""" line = str(j.get("full_location") or "").strip() \ or ", ".join(p for p in (j.get("city"), j.get("country")) if p) out: list[Place] = [] for part in line.split(";"): text = part.strip() add_place(out, place(text)) return out def rows(data: dict[str, Any], slug: str) -> list[Row]: """One page: each `jobs[].data` has `slug` (equal to `req_id`), `title`, the HTML `description` and, on some, `qualifications`, `full_location` ("Amsterdam, Netherlands; Manchester, United Kingdom" for several), `city` and `country`, `categories`, `posted_date` and `apply_url`, on the iCIMS site. The `salary_*` fields were 0 on every role and there is no currency, so no pay is read; nothing says remote (`location_type` is a kind of coordinates).""" out = [] for job in data.get("jobs") or []: j = job.get("data") or {} title = (j.get("title") or "").strip() role = str(j.get("slug") or j.get("req_id") or "") categories = j.get("categories") or [] text = "\n".join(p for p in (html_text(j.get("description")), html_text(j.get("qualifications"))) if p) places = _places(j) row: Row = { "source_id": role, "title": title, "places": places, "location": "; ".join(p["text"] for p in places), "url": f"https://{slug.lower()}/jobs/{role}", "posted": parse_dt(j.get("posted_date")), "department": str((categories[0] if categories else {}).get("name") or "").strip(), "description": text, "remote": None, "salary_text": "", } # One code, for a role at one place: over several countries it would # gate the others by the site's own. code = str(j.get("country_code") or "").strip() if len(places) == 1 and code: row["country"] = code if employment := str(j.get("employment_type") or "").strip(): row["employment"] = employment out.append(row) return out