Read Eightfold career sites through the PCSX search
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bd4121be91
commit
85bfe62fec
4 files changed
+550
No files matched your search
@@ -0,0 +1,169 @@
|
||||
"""Eightfold: `eightfold:<tenant host>/<domain>`, for example
|
||||
`eightfold:infineon.eightfold.ai/infineon.com` or, for a career site on the
|
||||
company's own host, `eightfold:jobs.ericsson.com/ericsson.com`. The public
|
||||
PCSX search, paged by offset at ten roles a page with the total stated, and a
|
||||
role's text on its own request.
|
||||
|
||||
Written from Ericsson's site on 2026-09-29 (637 roles), with Infineon's and
|
||||
Microsoft's read the same day in the findings. Unverified on a tenant other
|
||||
than those three: that the search takes the same parameters and answers with
|
||||
the same fields.
|
||||
|
||||
The `domain` is the tenant's own name for the company, usually the company's
|
||||
domain, and it is not the host: the site's page carries it as `domain=` in its
|
||||
links. `/api/apply/v2/jobs` answers 403 "Not authorized for PCSX" on the sites
|
||||
tried, so it is not used.
|
||||
|
||||
The search ignores `num` and answers ten roles a page, so a board costs one
|
||||
request per ten roles, and `ats.MAX_PAGES` (100) stops a read at 1,000 roles: a
|
||||
larger board (Infineon's 1,292, Microsoft's 2,319) is read incomplete every pull,
|
||||
and an incomplete read never closes the roles it did not list. The rows are
|
||||
sorted newest first (`sort_by=timestamp`) so that what the cap keeps is the
|
||||
newest thousand and the pages do not shuffle between two requests, unlike the
|
||||
default order, which puts hot roles first. The search does take a `location`
|
||||
free text (Ericsson's "Sweden" found 157 of 637), which could bring a read
|
||||
under the cap, but a target names no filter and none is built here.
|
||||
|
||||
Discovery names Eightfold from an `eightfold.ai` link, and the host and the
|
||||
domain from one that carries `domain=`.
|
||||
"""
|
||||
|
||||
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, is_web_url, only, parse_dt
|
||||
|
||||
NAME = "eightfold"
|
||||
LABEL = "Eightfold"
|
||||
PATTERNS = (
|
||||
# Both parts, from a link to a tenant's site that says its domain.
|
||||
r"https?://([a-z0-9-]+\.eightfold\.ai)/[^\s\"'<>]*?[?&]domain=([a-z0-9.-]+\.[a-z]{2,})",
|
||||
# No slug: a link to a tenant's site that does not.
|
||||
r"[a-z0-9-]+\.eightfold\.ai",
|
||||
)
|
||||
|
||||
#: A whole host name: two labels or more, the last one letters, so neither an
|
||||
#: address, a bare word nor a port names a site. `ats._get` refuses every host
|
||||
#: but the tenant's, redirects included.
|
||||
_NAME = 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.
|
||||
_LOCAL = (".localhost", ".local", ".internal", ".lan", ".home.arpa")
|
||||
|
||||
#: `workLocationOption` -> `store._remote`'s words. Only "onsite" and "hybrid"
|
||||
#: were seen; the other spellings are the obvious ones.
|
||||
_REMOTE = {"onsite": "onsite", "on_site": "onsite", "hybrid": "hybrid", "remote": "remote"}
|
||||
|
||||
|
||||
def parts(slug: str) -> tuple[str, str]:
|
||||
"""`(host, domain)` of a slug, lowercased."""
|
||||
host, _, domain = slug.lower().partition("/")
|
||||
return host, domain
|
||||
|
||||
|
||||
def _name_ok(name: str) -> bool:
|
||||
return bool(_NAME.fullmatch(name)) and not name.endswith(_LOCAL)
|
||||
|
||||
|
||||
def slug_ok(slug: str) -> bool:
|
||||
host, sep, domain = slug.lower().partition("/")
|
||||
return bool(sep) and _name_ok(host) and _name_ok(domain)
|
||||
|
||||
|
||||
def allowed(slug: str) -> Callable[[str], bool]:
|
||||
return only(parts(slug)[0])
|
||||
|
||||
|
||||
def careers_url(slug: str) -> str:
|
||||
return f"https://{parts(slug)[0]}/careers"
|
||||
|
||||
|
||||
def robots_page(slug: str) -> str:
|
||||
return careers_url(slug)
|
||||
|
||||
|
||||
def page(get: Get, slug: str, cursor: Any) -> Page:
|
||||
"""One page of `/api/pcsx/search` -> `{"status": 200, "data": {"positions":
|
||||
[...], "count": n}}`; the next starts at the offset after this page's
|
||||
positions, and an empty page ends the read."""
|
||||
host, domain = parts(slug)
|
||||
start = int(cursor or 0)
|
||||
answer = json.loads(get(f"https://{host}/api/pcsx/search?domain={domain}"
|
||||
f"&sort_by=timestamp&start={start}"))
|
||||
data = answer.get("data") if isinstance(answer, dict) else None
|
||||
positions = data.get("positions") if isinstance(data, dict) else None
|
||||
if not isinstance(positions, list):
|
||||
raise ValueError("not an Eightfold search answer: no data.positions"
|
||||
+ (f" (status {answer.get('status')})" if isinstance(answer, dict) else ""))
|
||||
count = data.get("count")
|
||||
results = [{"id": str(p.get("id") or "")} for p in positions]
|
||||
return (positions, results, count if isinstance(count, int) else None,
|
||||
start + len(positions) if positions else None)
|
||||
|
||||
|
||||
def _place(locations: Any) -> str:
|
||||
"""The role's places, "; " apart. Eightfold writes each as "city,region,
|
||||
country" with no space and repeats the name when a city is its own region
|
||||
("Mexico City,Mexico City,Mexico"), so the repeats go."""
|
||||
out: list[str] = []
|
||||
for loc in locations if isinstance(locations, list) else []:
|
||||
names: list[str] = []
|
||||
for name in str(loc).split(","):
|
||||
name = name.strip()
|
||||
if name and name not in names:
|
||||
names.append(name)
|
||||
if names and ", ".join(names) not in out:
|
||||
out.append(", ".join(names))
|
||||
return "; ".join(out)
|
||||
|
||||
|
||||
def rows(positions: list[dict[str, Any]], slug: str) -> list[Row]:
|
||||
"""A position has `id` (a number, kept as a string), `displayJobId`,
|
||||
`name`, `locations`, `postedTs` (epoch seconds), `department`,
|
||||
`workLocationOption` and `positionUrl`, the path of the role's page on the
|
||||
tenant's host. The list has no text, and no pay is stated anywhere."""
|
||||
host = parts(slug)[0]
|
||||
out = []
|
||||
for p in positions:
|
||||
title = (p.get("name") or "").strip()
|
||||
source_id = str(p.get("id") or "")
|
||||
path = str(p.get("positionUrl") or "").strip()
|
||||
url = f"https://{host}{path}" if path.startswith("/") and path[1:2] != "/" else ""
|
||||
if not title or not source_id or not is_web_url(url):
|
||||
continue
|
||||
out.append({
|
||||
"source_id": source_id,
|
||||
"title": title,
|
||||
"location": _place(p.get("locations") or p.get("standardizedLocations")),
|
||||
"url": url,
|
||||
"posted": parse_dt(p.get("postedTs")),
|
||||
"department": str(p.get("department") or "").strip(),
|
||||
"description": "",
|
||||
"remote": _REMOTE.get(str(p.get("workLocationOption") or "").strip().lower()),
|
||||
"salary_text": "",
|
||||
})
|
||||
return out
|
||||
|
||||
|
||||
def detail(get: Get, slug: str, row: Row) -> dict[str, Any]:
|
||||
"""`/api/pcsx/position_details` of the role -> `data.jobDescription`, the
|
||||
HTML text of the ad. The same answer repeats the listing's fields, and
|
||||
`publicUrl`, none of which is needed."""
|
||||
host, domain = parts(slug)
|
||||
role = str(row["source_id"])
|
||||
if not role.isdigit():
|
||||
raise ValueError(f"not an Eightfold position id: {role!r}")
|
||||
answer = json.loads(get(f"https://{host}/api/pcsx/position_details"
|
||||
f"?position_id={role}&domain={domain}&hl=en"))
|
||||
data = answer.get("data") if isinstance(answer, dict) else None
|
||||
if not isinstance(data, dict) or "jobDescription" not in data:
|
||||
raise ValueError("not an Eightfold position: no data.jobDescription")
|
||||
text = html.unescape(strip_html(data["jobDescription"] or ""))
|
||||
return {"description": " ".join(text.split())}
|
||||
Reference in new issue
Block a user