Every import, test and live doc follows the new path; behaviour is unchanged. tests/test_atshosts.py becomes tests/test_readers.py. plan-readers.md and review-ingest.md keep the old name, since they describe the state before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
133 lines
5.3 KiB
Python
133 lines
5.3 KiB
Python
"""Jibe (iCIMS Jibe): `jibe:<host>`, 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/<slug>` on the host, which redirects to the site's own
|
|
path (`/booking/jobs/<slug>` 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 html
|
|
import json
|
|
import re
|
|
from collections.abc import Callable
|
|
from typing import Any
|
|
|
|
from desk.sources import strip_html
|
|
|
|
from ._shared import Get, Page, Row, only, parse_dt
|
|
|
|
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 robots_page(slug: str) -> str:
|
|
return careers_url(slug)
|
|
|
|
|
|
def page(get: Get, slug: str, cursor: Any) -> 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 _plain(markup: Any) -> str:
|
|
return " ".join(html.unescape(strip_html(str(markup or ""))).split())
|
|
|
|
|
|
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 "")
|
|
if not title or not role:
|
|
continue
|
|
categories = j.get("categories") or []
|
|
text = "\n\n".join(p for p in (_plain(j.get("description")),
|
|
_plain(j.get("qualifications"))) if p)
|
|
out.append({
|
|
"source_id": role,
|
|
"title": title,
|
|
"location": (j.get("full_location")
|
|
or ", ".join(p for p in (j.get("city"), j.get("country")) if p)).strip(),
|
|
"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": "",
|
|
})
|
|
return out
|