Merge branch 'wp5-oracle-phenom'
This commit is contained in:
commit
c18c93a55e
10 files changed
+1753
No files matched your search
@@ -0,0 +1,183 @@
|
||||
"""Oracle Recruiting Cloud: `oracle:<host>/<siteNumber>`, for example
|
||||
`oracle:fa-ewto-saasfaprod1.fa.ocs.oraclecloud.com/CX_1001`. A paged REST
|
||||
listing that states its total, and a per-role resource for the description.
|
||||
|
||||
The host is the tenant's Fusion pod (`fa-...ocs.oraclecloud.com`), not the
|
||||
company's own domain: Nokia's `jobs.nokia.com` only redirects to it. The site
|
||||
number is `CX_1001` or `CX_1` on the tenants read so far, and the site's own
|
||||
name (`SinchCareer`) is taken in its place. Written from live boards on
|
||||
2026-09-29 (Milestone Systems, Nokia, Danske Bank, Sinch); jobhunt-hq did not
|
||||
read Oracle.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import html
|
||||
import json
|
||||
import re
|
||||
from collections.abc import Callable
|
||||
from typing import Any
|
||||
from urllib.parse import quote
|
||||
|
||||
from desk.sources import strip_html
|
||||
|
||||
from ._shared import Get, Page, Row, only, parse_dt
|
||||
|
||||
NAME = "oracle"
|
||||
LABEL = "Oracle Recruiting Cloud"
|
||||
KEEP_CASE = True
|
||||
PATTERNS = (
|
||||
# The candidate site or one role's page: `<pod>/hcmUI/CandidateExperience/en/sites/CX_1/jobs`.
|
||||
r"https?://([a-z0-9-]+(?:\.[a-z0-9-]+)*\.oraclecloud\.(?:com|eu))"
|
||||
r"/hcmUI/CandidateExperience/[A-Za-z_-]+/sites/([A-Za-z0-9_-]+)",
|
||||
# The REST call a company's own page makes, which names the site as `siteNumber=`.
|
||||
r"https?://([a-z0-9-]+(?:\.[a-z0-9-]+)*\.oraclecloud\.(?:com|eu))"
|
||||
r"/hcmRestApi/resources/[a-z0-9.]+/recruitingCEJobRequisitions[^\"'\s]*?siteNumber=([A-Za-z0-9_-]+)",
|
||||
# No slug: another page of a tenant's Fusion UI (its sign-in, say), which names
|
||||
# the host but no candidate site.
|
||||
r"oraclecloud\.(?:com|eu)/hcmUI(?!/CandidateExperience/[A-Za-z_-]+/sites/)",
|
||||
)
|
||||
|
||||
#: The page size asked for. 200 was answered in full by Nokia (600 roles in
|
||||
#: three calls of about 360 KB, 2026-09-29); the cursor advances by what a page
|
||||
#: returned, so a tenant that caps `limit` lower would not skip a role.
|
||||
PAGE_SIZE = 200
|
||||
|
||||
#: A pod: `fa-ewto-saasfaprod1.fa.ocs.oraclecloud.com`. Oracle's regions also
|
||||
#: use `.eu` (Danske Bank's `ejqi.fa.ocs.oraclecloud.eu`). A host name has no
|
||||
#: case, so a slug written with capitals is allowed as its lowercase.
|
||||
_HOST = r"[a-z0-9-]+(?:\.[a-z0-9-]+)*\.oraclecloud\.(?:com|eu)"
|
||||
_SLUG = re.compile(rf"({_HOST})/([A-Za-z0-9_-]+)", re.IGNORECASE)
|
||||
|
||||
#: `WorkplaceTypeCode` -> `store._remote`'s words. A role that states none
|
||||
#: has an empty code, which stays unknown.
|
||||
_REMOTE = {"ora_remote": "remote", "ora_hybrid": "hybrid", "ora_on_site": "onsite"}
|
||||
|
||||
|
||||
def _parts(slug: str) -> tuple[str, str]:
|
||||
"""`(host, site number)` of a slug that passed `slug_ok`."""
|
||||
host, _, site = slug.partition("/")
|
||||
return host.lower(), site
|
||||
|
||||
|
||||
def slug_ok(slug: str) -> bool:
|
||||
return bool(_SLUG.fullmatch(slug))
|
||||
|
||||
|
||||
def allowed(slug: str) -> Callable[[str], bool]:
|
||||
return only(_parts(slug)[0])
|
||||
|
||||
|
||||
def _base(slug: str) -> str:
|
||||
host, site = _parts(slug)
|
||||
return f"https://{host}/hcmUI/CandidateExperience/en/sites/{site}"
|
||||
|
||||
|
||||
def careers_url(slug: str) -> str:
|
||||
return f"{_base(slug)}/jobs"
|
||||
|
||||
|
||||
def robots_page(slug: str) -> str:
|
||||
return careers_url(slug)
|
||||
|
||||
|
||||
def _api(slug: str) -> str:
|
||||
return f"https://{_parts(slug)[0]}/hcmRestApi/resources/latest"
|
||||
|
||||
|
||||
def page(get: Get, slug: str, cursor: Any) -> Page:
|
||||
"""One page of `recruitingCEJobRequisitions`. The answer's outer `count`,
|
||||
`hasMore` and `limit` describe the one search wrapper in `items`, so the
|
||||
total (`TotalJobsCount`) and the roles (`requisitionList`) are read from
|
||||
`items[0]`. Without the `expand` only the facets come back; asking for
|
||||
`requisitionList.secondaryLocations` gives the roles and each one's other
|
||||
locations, which the plain `requisitionList` leaves out. Past the last role
|
||||
the list is empty."""
|
||||
offset = int(cursor or 0)
|
||||
site = _parts(slug)[1]
|
||||
data = json.loads(get(
|
||||
f"{_api(slug)}/recruitingCEJobRequisitions?onlyData=true"
|
||||
f"&expand=requisitionList.secondaryLocations"
|
||||
f"&finder=findReqs;siteNumber={site},limit={PAGE_SIZE},offset={offset}"))
|
||||
search = (data.get("items") or [{}])[0]
|
||||
roles = search.get("requisitionList") or []
|
||||
# `_paged` counts `id`, which Oracle spells `Id`.
|
||||
results = [{"id": str(role.get("Id") or "")} for role in roles]
|
||||
return search, results, search.get("TotalJobsCount"), offset + len(roles) if roles else None
|
||||
|
||||
|
||||
def parse(body: bytes, slug: str) -> list[Row]:
|
||||
return rows((json.loads(body).get("items") or [{}])[0], slug)
|
||||
|
||||
|
||||
def _text(value: Any) -> str:
|
||||
return value.strip() if isinstance(value, str) else ""
|
||||
|
||||
|
||||
def _plain(value: Any) -> str:
|
||||
"""Plain text from a field of HTML, entities (`&`, ` `) included."""
|
||||
return html.unescape(strip_html(_text(value))).replace("\xa0", " ").strip()
|
||||
|
||||
|
||||
def rows(search: dict[str, Any], slug: str) -> list[Row]:
|
||||
"""The roles of one page's search wrapper. The list carries the title, the
|
||||
id, `PostedDate` (a date), `PrimaryLocation` ("Copenhagen, Denmark"; a
|
||||
country alone where the role names no city), `secondaryLocations`,
|
||||
`WorkplaceTypeCode` and `ShortDescriptionStr`, one paragraph that Nokia
|
||||
and Milestone fill for most roles. The department fields (`JobFamily`,
|
||||
`Department`, `Organization`) were null on every role of all four boards
|
||||
read, and are taken when a tenant fills them. The full description is in
|
||||
the role's own resource, see `detail`. No pay is stated."""
|
||||
out = []
|
||||
for role in search.get("requisitionList") or []:
|
||||
role_id = str(role.get("Id") or "").strip()
|
||||
title = _text(role.get("Title"))
|
||||
# The id goes into a URL, and a listing is external content.
|
||||
if not title or not re.fullmatch(r"[A-Za-z0-9_-]+", role_id):
|
||||
continue
|
||||
places: list[str] = []
|
||||
for name in (_text(role.get("PrimaryLocation")),
|
||||
*(_text(s.get("Name")) for s in role.get("secondaryLocations") or []
|
||||
if isinstance(s, dict))):
|
||||
if name and name not in places:
|
||||
places.append(name)
|
||||
out.append({
|
||||
"source_id": role_id,
|
||||
"title": title,
|
||||
"location": "; ".join(places),
|
||||
"url": f"{_base(slug)}/job/{role_id}",
|
||||
"posted": parse_dt(role.get("PostedDate")),
|
||||
"department": (_text(role.get("JobFamily")) or _text(role.get("JobFunction"))
|
||||
or _text(role.get("Department")) or _text(role.get("Organization"))),
|
||||
"description": _plain(role.get("ShortDescriptionStr")),
|
||||
"remote": _REMOTE.get(_text(role.get("WorkplaceTypeCode")).lower()),
|
||||
"salary_text": "", # the resource states no pay
|
||||
})
|
||||
return out
|
||||
|
||||
|
||||
def detail(get: Get, slug: str, row: Row) -> dict[str, Any]:
|
||||
"""The role's own resource (`recruitingCEJobRequisitionDetails`, found by
|
||||
`Id` and site). Only here is the full text: `ExternalDescriptionStr`, with
|
||||
the responsibilities and qualifications strings after it where a tenant
|
||||
fills them (Milestone leaves them empty), all HTML. `ExternalPostedStartDate`
|
||||
is a timestamp where the listing has a date. A role that is no longer open
|
||||
answers 200 with no items, and has nothing to read."""
|
||||
site = _parts(slug)[1]
|
||||
role_id = quote(str(row["source_id"]), safe="")
|
||||
data = json.loads(get(
|
||||
f"{_api(slug)}/recruitingCEJobRequisitionDetails?expand=all&onlyData=true"
|
||||
f"&finder=ById;Id=%22{role_id}%22,siteNumber={site}"))
|
||||
items = data.get("items") or []
|
||||
if not items:
|
||||
return {}
|
||||
role = items[0]
|
||||
text = " ".join(part for key in ("ExternalDescriptionStr", "ExternalResponsibilitiesStr",
|
||||
"ExternalQualificationsStr")
|
||||
if (part := _plain(role.get(key))))
|
||||
out: dict[str, Any] = {}
|
||||
if text:
|
||||
out["description"] = text
|
||||
if posted := parse_dt(role.get("ExternalPostedStartDate")):
|
||||
out["posted"] = posted
|
||||
return out
|
||||
@@ -0,0 +1,229 @@
|
||||
"""Phenom: `phenom:<host>/<country>/<lang>`, the career site a company runs
|
||||
on its own domain, at the locale root it uses: `phenom:careers.king.com/us/en`,
|
||||
`phenom:www.careers.philips.com/global/en`. A JSON search that pages by offset
|
||||
and states its total.
|
||||
|
||||
The listing is the `POST /widgets` call the site's own search page makes. It
|
||||
answered without a cookie, an `Origin` header, a `pageId` or the site's
|
||||
`refNum`, so the body carries none of them: only the locale (`lang`,
|
||||
`country`, both read off the slug's path) and the paging. Nothing is taken
|
||||
from the page's script. Written from live sites on 2026-09-29 (King, Just Eat
|
||||
Takeaway, Philips); jobhunt-hq did not read Phenom.
|
||||
"""
|
||||
|
||||
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 = "phenom"
|
||||
LABEL = "Phenom"
|
||||
PATTERNS = (
|
||||
# A link to the site's search page, the one URL of a Phenom site that carries
|
||||
# both the host and the locale root and is named the same on every one.
|
||||
r"https?://([a-z0-9-]+(?:\.[a-z0-9-]+)*\.[a-z][a-z0-9-]*)/([a-z]{2,8})/([a-z]{2})/search-results",
|
||||
# No slug: a page that loads Phenom's own assets, on a site whose locale
|
||||
# root discovery has not seen. The host is known, the board is not.
|
||||
r"phenompeople\.com|phenom\.com/careers",
|
||||
)
|
||||
|
||||
#: The page size asked for. 100 is what the site's own search sends; `size`
|
||||
#: 200 was answered in full by Just Eat Takeaway and 500 by Philips (of 865),
|
||||
#: but a page is 340 KB at 100 roles already.
|
||||
PAGE_SIZE = 100
|
||||
|
||||
#: A DNS name with a dot and a letter first in its last label, so an address
|
||||
#: (`127.0.0.1`) or a single word (`localhost`) never names a site the fetch
|
||||
#: could be pointed at; `ats._get` still refuses local names and every host
|
||||
#: but this one, redirects included. Then the locale root: `country/lang`,
|
||||
#: which every Phenom site read so far writes as `global/en`, `na/en`, `us/en`.
|
||||
_SLUG = re.compile(r"[a-z0-9-]+(?:\.[a-z0-9-]+)*\.[a-z][a-z0-9-]*/[a-z]{2,8}/[a-z]{2}")
|
||||
|
||||
|
||||
def _parts(slug: str) -> tuple[str, str, str]:
|
||||
"""`(host, country, lang)` of a slug that passed `slug_ok`."""
|
||||
host, country, lang = slug.split("/")
|
||||
return host, country, lang
|
||||
|
||||
|
||||
def slug_ok(slug: str) -> bool:
|
||||
return bool(_SLUG.fullmatch(slug))
|
||||
|
||||
|
||||
def allowed(slug: str) -> Callable[[str], bool]:
|
||||
return only(_parts(slug)[0])
|
||||
|
||||
|
||||
def _root(slug: str) -> str:
|
||||
host, country, lang = _parts(slug)
|
||||
return f"https://{host}/{country}/{lang}"
|
||||
|
||||
|
||||
def careers_url(slug: str) -> str:
|
||||
return f"{_root(slug)}/search-results"
|
||||
|
||||
|
||||
def robots_page(slug: str) -> str:
|
||||
return careers_url(slug)
|
||||
|
||||
|
||||
def _body(slug: str, offset: int) -> dict[str, Any]:
|
||||
"""What the site's search page sends for a listing of every role, newest
|
||||
first, less the parts that only tell the page what to draw. `lang` is
|
||||
`en_global` for `/global/en` and `en_us` for `/us/en`, the site's own
|
||||
spelling on the three sites read."""
|
||||
_host, country, lang = _parts(slug)
|
||||
return {
|
||||
"lang": f"{lang}_{country}", "deviceType": "desktop", "country": country,
|
||||
"pageName": "search-results", "ddoKey": "refineSearch", "sortBy": "",
|
||||
"subsearch": "", "from": offset, "jobs": True, "counts": True, "all_fetch": False,
|
||||
"pageType": "landingPage", "size": PAGE_SIZE, "clearAll": False,
|
||||
"jdsource": "facets", "isSliderEnable": False, "siteType": "external",
|
||||
"location": "", "keywords": "", "global": True, "selected_fields": {},
|
||||
"sort": {"order": "desc", "field": "postedDate"}, "locationData": {},
|
||||
}
|
||||
|
||||
|
||||
def _key(job: dict[str, Any]) -> str:
|
||||
"""The role's id on the board: `jobSeqNo`, which carries the site and the
|
||||
language and is the one of the three ids (`jobSeqNo`, `jobId`, `reqId`)
|
||||
that the site's job page takes on every site read. `reqId` is not unique
|
||||
across languages."""
|
||||
return str(job.get("jobSeqNo") or job.get("jobId") or job.get("reqId") or "").strip()
|
||||
|
||||
|
||||
def page(get: Get, slug: str, cursor: Any) -> Page:
|
||||
offset = int(cursor or 0)
|
||||
host = _parts(slug)[0]
|
||||
data = json.loads(get(f"https://{host}/widgets", method="POST",
|
||||
payload=_body(slug, offset)))
|
||||
search = data.get("refineSearch")
|
||||
if not isinstance(search, dict) or search.get("status", 200) != 200:
|
||||
raise ValueError("not a Phenom search answer: no refineSearch")
|
||||
jobs = (search.get("data") or {}).get("jobs") or []
|
||||
results = [{"id": _key(job)} for job in jobs]
|
||||
return search, results, search.get("totalHits"), offset + len(jobs) if jobs else None
|
||||
|
||||
|
||||
def parse(body: bytes, slug: str) -> list[Row]:
|
||||
return rows(json.loads(body).get("refineSearch") or {}, slug)
|
||||
|
||||
|
||||
def _text(value: Any) -> str:
|
||||
return value.strip() if isinstance(value, str) else ""
|
||||
|
||||
|
||||
def _plain(value: Any) -> str:
|
||||
return html.unescape(strip_html(_text(value))).replace("\xa0", " ").strip()
|
||||
|
||||
|
||||
def _slug_of(title: str) -> str:
|
||||
"""The decorative last part of a role's URL, its title with runs of
|
||||
anything but letters and digits as one dash; it matches the site's own
|
||||
(checked on all 32 roles of King's sitemap). The page is found by the id."""
|
||||
return re.sub(r"[^A-Za-z0-9]+", "-", title).strip("-")
|
||||
|
||||
|
||||
def rows(search: dict[str, Any], slug: str) -> list[Row]:
|
||||
"""The roles of one page, `refineSearch.data.jobs`. A role has the title,
|
||||
`jobSeqNo`, `postedDate` (a date at midnight), `category`, the locations
|
||||
as `multi_location` (a list, one per place) beside `location` (the first),
|
||||
and `descriptionTeaser`, the first paragraph of the text; the full text is
|
||||
on the role's page, see `detail`. `applyUrl` points at the apply system
|
||||
(Workday for Just Eat Takeaway and Philips), so the role's URL is its page
|
||||
on the site. No remote flag and no pay are in the list."""
|
||||
out = []
|
||||
for job in search.get("data", {}).get("jobs") or []:
|
||||
key = _key(job)
|
||||
title = _text(job.get("title"))
|
||||
if not title or not key:
|
||||
continue
|
||||
places: list[str] = []
|
||||
for place in (*(job.get("multi_location") or []), job.get("location")):
|
||||
if isinstance(place, str) and place.strip() and place.strip() not in places:
|
||||
places.append(place.strip())
|
||||
tail = _slug_of(title)
|
||||
out.append({
|
||||
"source_id": key,
|
||||
"title": title,
|
||||
"location": "; ".join(places),
|
||||
"url": f"{_root(slug)}/job/{key}" + (f"/{tail}" if tail else ""),
|
||||
"posted": parse_dt(job.get("postedDate")),
|
||||
"department": _text(job.get("category")),
|
||||
"description": _plain(job.get("descriptionTeaser")),
|
||||
"remote": None, # the list does not say
|
||||
"salary_text": "", # nor does it state pay
|
||||
})
|
||||
return out
|
||||
|
||||
|
||||
#: The JSON-LD blocks of a page; a Phenom job page has one `JobPosting` and,
|
||||
#: on Philips's, a `BreadcrumbList` and more.
|
||||
_JSON_LD = re.compile(r"<script[^>]+application/ld\+json[^>]*>(.*?)</script>", re.S | re.I)
|
||||
|
||||
|
||||
#: Where a page assigns its state, and the words its `checkRemote` says that
|
||||
#: `store._remote` reads (King's pages say "On-site"; no other was seen).
|
||||
_STATE = "phApp.ddo = "
|
||||
_REMOTE = {"remote": "remote", "hybrid": "hybrid", "on-site": "onsite", "onsite": "onsite"}
|
||||
|
||||
|
||||
def _job_posting(body: str) -> dict[str, Any]:
|
||||
"""The `JobPosting` among a page's JSON-LD blocks, or {}."""
|
||||
for block in _JSON_LD.findall(body):
|
||||
try:
|
||||
found = json.loads(block)
|
||||
except ValueError:
|
||||
continue
|
||||
for candidate in found if isinstance(found, list) else [found]:
|
||||
if isinstance(candidate, dict) and candidate.get("@type") == "JobPosting":
|
||||
return candidate
|
||||
return {}
|
||||
|
||||
|
||||
def _page_job(body: str) -> dict[str, Any]:
|
||||
"""The role as the page's own state holds it, `phApp.ddo.jobDetail.data.job`,
|
||||
or {}. King's pages of roles posted the same day had no `JobPosting`, and
|
||||
this had the full description. Only that one object is read: the state
|
||||
around it holds the site's session values, which nothing here uses."""
|
||||
start = body.find(_STATE)
|
||||
if start < 0:
|
||||
return {}
|
||||
try:
|
||||
state, _end = json.JSONDecoder().raw_decode(body, start + len(_STATE))
|
||||
job = state["jobDetail"]["data"]["job"]
|
||||
except (ValueError, KeyError, TypeError):
|
||||
return {}
|
||||
return job if isinstance(job, dict) else {}
|
||||
|
||||
|
||||
def detail(get: Get, slug: str, row: Row) -> dict[str, Any]:
|
||||
"""The full description from the role's page: the `JobPosting` in its
|
||||
JSON-LD, whose `description` is HTML with its entities escaped (`<p>`
|
||||
and `&` inside), so it is unescaped, stripped and unescaped again; or,
|
||||
where the page has none, the page state's own `description`, which is
|
||||
plain HTML. A page with neither raises, so the role is asked again on a
|
||||
later pull instead of counting as read with no text. `datePosted` is taken
|
||||
as `posted`: it can be earlier than the list's `postedDate` (Philips's list
|
||||
said the day of the read for a role whose page said 2026-09-08), and a role
|
||||
keeps the earliest date it ever had. King's page state says `checkRemote`."""
|
||||
body = get(row["url"], headers={"Accept": "text/html"}).decode("utf-8", "replace")
|
||||
posting, job = _job_posting(body), _page_job(body)
|
||||
out: dict[str, Any] = {}
|
||||
if description := (_plain(html.unescape(_text(posting.get("description"))))
|
||||
or _plain(job.get("description"))):
|
||||
out["description"] = description
|
||||
else:
|
||||
raise ValueError("no description on the role's page")
|
||||
if posted := parse_dt(posting.get("datePosted")):
|
||||
out["posted"] = posted
|
||||
if remote := _REMOTE.get(_text(job.get("checkRemote")).lower()):
|
||||
out["remote"] = remote
|
||||
return out
|
||||
Reference in new issue
Block a user