Read Pinpoint boards from their postings.json

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Sonnet 5.5 committed 2026-09-29 20:00:52 +02:00
1 parent a6aff2ea2f
commit 0b76b16daa
3 files changed
+305

No files matched your search

+149
View File
@@ -0,0 +1,149 @@
"""Pinpoint: `pinpoint:<subdomain>` for acme.pinpointhq.com, the whole board
in one JSON answer. There is no probe: an unknown subdomain's answer was not
checked, and a board is found by the link a career site carries.
Written from Xeneta's board on 2026-09-29 (two roles); jobhunt-hq did not read
Pinpoint. Unverified: whether a large board pages `/postings.json` (the answer
has a `data` list and no paging keys, so every board is read as complete
here), and the spelling of `compensation_frequency`, since no board read so far
shows its pay (`compensation_visible` was false on both roles). A board shared
by several brands (inMusic's, with Native Instruments on it) is read whole;
there is no filter on `job.division`.
There is no posted date in the listing, only in each posting's page as JSON-LD,
so `posted` stays None rather than costing a request a role for it.
"""
from __future__ import annotations
import html
import json
from collections.abc import Callable
from typing import Any
from desk.sources import strip_html
from ._shared import Row, is_web_url, label_slug_ok, num, only, pay_line, yearly_amount
NAME = "pinpoint"
LABEL = "Pinpoint"
PATTERNS = (r"https?://([a-z0-9-]+)\.pinpointhq\.com",)
#: `workplace_type` -> `store._remote`'s words. Anything else says nothing.
_REMOTE = {"onsite": "onsite", "on_site": "onsite", "hybrid": "hybrid", "remote": "remote"}
#: `compensation_frequency` -> the multiplier that makes a figure yearly. The
#: spellings are a guess, since no board read so far states pay; a frequency
#: not listed leaves the yearly columns empty, and `salary_text` still says it.
_YEARLY = {"annually": 1, "annual": 1, "yearly": 1, "year": 1, "monthly": 12, "month": 12}
#: `compensation_frequency` -> the word `salary_text` says after "per".
_PERIOD = {"annually": "year", "annual": "year", "yearly": "year", "monthly": "month",
"weekly": "week", "daily": "day", "hourly": "hour"}
#: The sections of a posting's text, in the order the page shows them: the
#: description, then these fields, each with its own heading in `<field>_header`.
_SECTIONS = ("key_responsibilities", "skills_knowledge_expertise", "benefits")
def host(slug: str) -> str:
return f"{slug.lower()}.pinpointhq.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)}/"
def robots_page(slug: str) -> str:
return careers_url(slug)
def feed_url(slug: str) -> str:
return f"https://{host(slug)}/postings.json"
def _plain(markup: Any) -> str:
"""HTML as one line of plain text: the tags out, the entities read (Pinpoint
writes `&amp;` and `&nbsp;`), the whitespace, non-breaking included, collapsed."""
return " ".join(html.unescape(strip_html(str(markup or ""))).split())
def _text(j: dict[str, Any]) -> str:
"""The description and the sections after it, each section under its own
heading, as plain text with a blank line between them."""
parts = [_plain(j.get("description"))]
for field in _SECTIONS:
body = _plain(j.get(field))
if body:
heading = str(j.get(f"{field}_header") or "").strip()
parts.append(f"{heading}: {body}" if heading else body)
return "\n\n".join(p for p in parts if p)
def _place(location: dict[str, Any]) -> str:
"""The place's name, then its `province` where that says more. Pinpoint
fills `province` with a region or a country as the company typed it, so it
is kept only when it differs from the name."""
parts: list[str] = []
for part in (location.get("name") or location.get("city"), location.get("province")):
part = str(part or "").strip()
if part and part.lower() not in (p.lower() for p in parts):
parts.append(part)
return ", ".join(parts)
def _pay(j: dict[str, Any]) -> tuple[int | None, int | None, str, str]:
"""`(salary_min, salary_max, currency, salary_text)` of a posting whose
pay is shown (`compensation_visible`); the free-text `compensation` is the
line when the bounds are not given."""
if not j.get("compensation_visible"):
return None, None, "", ""
lo, hi = num(j.get("compensation_minimum")), num(j.get("compensation_maximum"))
frequency = str(j.get("compensation_frequency") or "").strip().lower()
period = _PERIOD.get(frequency, frequency)
text = pay_line(lo, hi, j.get("compensation_currency"), period)
text = text or str(j.get("compensation") or "").strip()
low, high, code = yearly_amount(lo, hi, j.get("compensation_currency"), frequency, _YEARLY)
return low, high, code, text
def parse(body: bytes, slug: str) -> list[Row]:
"""`{slug}.pinpointhq.com/postings.json` -> `{"data": [...]}`. A posting has
`id`, `title`, `url`, `location` (`name`, `city`, `province`),
`workplace_type`, `job` (`requisition_id`, `department`, `division`), the
HTML `description` and its sections, and the `compensation_*` fields."""
data = json.loads(body)
if not isinstance(data, dict) or not isinstance(data.get("data"), list):
raise ValueError("not a Pinpoint listing: no data list")
out = []
for j in data["data"]:
title = (j.get("title") or "").strip()
url = (j.get("url") or "").strip()
source_id = str(j.get("id") or "")
if not title or not source_id or not is_web_url(url):
continue
job = j.get("job") or {}
low, high, currency, salary_text = _pay(j)
out.append({
"source_id": source_id,
"title": title,
"location": _place(j.get("location") or {}),
"url": url,
"posted": None, # only the posting's own page has a date
"department": str((job.get("department") or {}).get("name") or "").strip(),
"description": _text(j),
"remote": _REMOTE.get(str(j.get("workplace_type") or "").strip().lower()),
"salary_text": salary_text,
"salary_min": low,
"salary_max": high,
"currency": currency,
})
return out
+1
View File
@@ -0,0 +1 @@
{"data":[{"id":"581878","benefits":"\u003cul\u003e\u003cli\u003e\u003c!--block--\u003eWe will help you \u003cstrong\u003egrow your career:\u003c/strong\u003e We help you identify areas of growth for you, whether you want to grow as a specialist in your field or eventually want to go into a leadership/management role.\u0026nbsp;\u003c/li\u003e\u003cli\u003e\u003c!--block--\u003eWe have a \u003cstrong\u003etransparent and open work environment\u003c/strong\u003e where everyone is empowered to make an impact and encouraged to voice their ideas.\u0026nbsp;\u003c/li\u003e\u003cli\u003e\u003c!--block--\u003eKeeping true to our value, “\u003cstrong\u003eXeneta is one”\u003c/strong\u003e, we regularly bring colleagues together across locations. We organize an annual global company trip, and we aim to create opportunities for people to meet in person from time to time.\u0026nbsp;\u003c/li\u003e\u003cli\u003e\u003c!--block--\u003eYou will receive an\u003cstrong\u003e individual education budget \u003c/strong\u003eand can educate yourself during work hours: you can spend several hours each month attending courses, reading books, or getting involved in communities.\u0026nbsp;\u003c/li\u003e\u003cli\u003e\u003c!--block--\u003eYou will enjoy our\u003cstrong\u003e generous vacation plan\u003c/strong\u003e: 26 paid days of vacation per year.\u003c/li\u003e\u003cli\u003e\u003c!--block--\u003eWe value \u003cstrong\u003ework-life balance \u003c/strong\u003eand want to make sure you can spend quality time with your family or enjoy your hobbies when your workday is over.\u0026nbsp;\u003c/li\u003e\u003cli\u003e\u003c!--block--\u003eWe have \u003cstrong\u003eflexible working hours\u003c/strong\u003e (core time with meetings is 11:00 to 16:00 EET, the rest is up to you).\u003c/li\u003e\u003cli\u003e\u003c!--block--\u003eFull-time position, employed through GI Group, our staffing partner in Romania.\u003c/li\u003e\u003c/ul\u003e\u003cdiv\u003e\u003c!--block--\u003e\u003cbr\u003eWhy you will love it here\u003c/div\u003e\u003cul\u003e\u003cli\u003e\u003c!--block--\u003e\u003cstrong\u003eOur Impact\u003c/strong\u003e: We’re category leaders digitalizing the way ocean and air freight is procured bringing on-demand actionable data to all industry stakeholders. We’re moving fast.\u0026nbsp;\u003c/li\u003e\u003cli\u003e\u003c!--block--\u003e\u003cstrong\u003eOur Technology\u003c/strong\u003e: Deep data analytics and integrations coupled with a scalable, sleek and beautiful user interface.\u0026nbsp;\u003c/li\u003e\u003cli\u003e\u003c!--block--\u003e\u003cstrong\u003eOur Team\u003c/strong\u003e: Shipping, consulting and tech all-stars on our roster.\u0026nbsp;\u003c/li\u003e\u003cli\u003e\u003c!--block--\u003e\u003cstrong\u003eOur Values\u003c/strong\u003e: Xeneta is One. Transparency builds trust. Ownership drives Impact. Modernization through data. Diversity is our Superpower.\u003c/li\u003e\u003c/ul\u003e\u003cdiv\u003e\u003c!--block--\u003eMake sure to highlight your past achievements that you think are relevant. Be sure to give us an idea of who you are as a real live person and not just your professional experience. \u0026nbsp;\u003cbr\u003e\u003cbr\u003e\u003c/div\u003e\u003cdiv\u003e\u003c!--block--\u003eXeneta is an equal opportunity employer. We celebrate diversity and are committed to creating an inclusive environment for all employees. \u0026nbsp;\u003cbr\u003e\u003cbr\u003e\u003c/div\u003e\u003cdiv\u003e\u003c!--block--\u003eLooking forward to hearing from you!\u0026nbsp;\u003c/div\u003e","benefits_header":"Job Benefits","compensation":null,"compensation_minimum":null,"compensation_maximum":null,"compensation_currency":null,"compensation_frequency":null,"compensation_visible":false,"deadline_at":null,"description":"\u003cdiv\u003e\u003c!--block--\u003e\u003cstrong\u003eData Detective Wanted to join our Data \u0026amp; Analytics Team\u003c/strong\u003e \u003cbr\u003e\u003cbr\u003e\u003cem\u003eLocation: Bucharest, Romania\u003c/em\u003e\u003cbr\u003e\u003cbr\u003eAs a \u003cstrong\u003eData Operations Analyst \u003c/strong\u003eat Xeneta, you’ll learn how to master complex data analytics within the world of supply chain and logistics. Xeneta is one of the world's leading data platforms providing market intelligence to the ocean and air freight industry. We have a big team of skilled Data Analysts that will help you learn the ropes from the ground up, while enabling you to collect and analyze data in one of the world’s greatest container shipping datasets. \u0026nbsp;\u003c/div\u003e\u003cdiv\u003e\u003c!--block--\u003e\u003cbr\u003eBring your analytical mindset and a genuine curiosity for how global shipping works and join our team!\u0026nbsp;\u003c/div\u003e","employment_type":"permanent_full_time","employment_type_text":"Permanent - Full Time","key_responsibilities":"\u003cdiv\u003e\u003c!--block--\u003eJoin our Liner Data \u0026amp; Analytics Team (LDAT) and own a portfolio of container shipping services for theLine truncated
+155
View File
@@ -0,0 +1,155 @@
"""The Pinpoint host module against a saved listing (Xeneta's whole board, two roles). No network."""
from __future__ import annotations
import json
import sys
from pathlib import Path
import httpx
import pytest
ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from app.jobs import discover # noqa: E402
from plugins import ats, atshosts # noqa: E402
from plugins.atshosts import pinpoint # noqa: E402
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
def _body() -> bytes:
return (FIXTURES / "pinpoint.json").read_bytes()
def test_a_listing_becomes_rows() -> None:
rows = pinpoint.parse(_body(), "xeneta")
assert [r["source_id"] for r in rows] == ["581878", "587635"]
first = rows[0]
assert first["title"] == "Data Operations Analyst - LSP"
assert first["url"] == ("https://xeneta.pinpointhq.com/en/postings/"
"a85d5d45-b334-4f5c-aaea-d0b399b08a2e")
assert first["location"] == "Bucharest" # the province repeats the name
assert first["department"] == "RMT - LSP"
assert first["remote"] == "hybrid"
assert first["posted"] is None # the listing has no date
assert (first["salary_text"], first["salary_min"], first["salary_max"],
first["currency"]) == ("", None, None, "")
def test_the_description_joins_the_sections_as_plain_text() -> None:
text = pinpoint.parse(_body(), "xeneta")[0]["description"]
assert text.startswith("Data Detective Wanted to join our Data & Analytics Team")
assert "<" not in text and "&amp;" not in text and "\xa0" not in text
assert "\n\nKey Responsibilities: Join our Liner Data & Analytics Team" in text
assert "\n\nSkills, Knowledge & Expertise: In this role" in text
assert "\n\nJob Benefits: We will help you grow your career:" in text
def test_a_region_is_kept_when_it_says_more_than_the_name() -> None:
body = json.loads(_body())
body["data"][0]["location"] = {"name": "London", "city": "London", "province": "England"}
body["data"][1]["location"] = {"name": "", "city": "Oslo", "province": "Norway"}
rows = pinpoint.parse(json.dumps(body).encode(), "xeneta")
assert [r["location"] for r in rows] == ["London, England", "Oslo, Norway"]
@pytest.mark.parametrize(("kind", "remote"), [
("onsite", "onsite"), ("hybrid", "hybrid"), ("remote", "remote"), ("", None), (None, None)])
def test_the_workplace_type_maps_to_the_remote_words(kind: str | None, remote: str | None) -> None:
body = json.loads(_body())
body["data"][0]["workplace_type"] = kind
assert pinpoint.parse(json.dumps(body).encode(), "xeneta")[0]["remote"] == remote
def test_pay_is_read_only_when_the_board_shows_it() -> None:
body = json.loads(_body())
pay = {"compensation_minimum": 60000, "compensation_maximum": 80000,
"compensation_currency": "EUR", "compensation_frequency": "annually"}
body["data"][0] |= pay | {"compensation_visible": True}
body["data"][1] |= pay # hidden: `compensation_visible` is false
first, second = pinpoint.parse(json.dumps(body).encode(), "xeneta")
assert (first["salary_min"], first["salary_max"], first["currency"]) == (60000, 80000, "EUR")
assert first["salary_text"] == "EUR 60,000 to 80,000 per year"
assert (second["salary_min"], second["salary_text"]) == (None, "")
def test_an_unknown_pay_frequency_keeps_the_text_and_leaves_the_columns() -> None:
body = json.loads(_body())
body["data"][0] |= {"compensation_minimum": 40, "compensation_maximum": 50,
"compensation_currency": "GBP", "compensation_frequency": "hourly",
"compensation_visible": True}
row = pinpoint.parse(json.dumps(body).encode(), "xeneta")[0]
assert row["salary_text"] == "GBP 40 to 50 per hour"
assert (row["salary_min"], row["salary_max"], row["currency"]) == (None, None, "")
def test_a_posting_without_a_title_or_an_id_or_a_web_url_is_left_out() -> None:
body = json.loads(_body())
body["data"][0]["title"] = ""
body["data"][1]["url"] = "javascript:alert(1)"
assert pinpoint.parse(json.dumps(body).encode(), "xeneta") == []
def test_an_empty_board_is_no_rows_and_a_page_that_is_not_a_listing_raises() -> None:
assert pinpoint.parse(b'{"data": []}', "xeneta") == []
for body in (b"<html></html>", b"[]", b'{"error": "nope"}'):
with pytest.raises(ValueError):
pinpoint.parse(body, "xeneta")
def test_the_board_is_read_through_the_app_and_is_complete() -> None:
seen: list[str] = []
def handler(request: httpx.Request) -> httpx.Response:
seen.append(str(request.url))
return httpx.Response(200, content=_body())
with httpx.Client(transport=httpx.MockTransport(handler)) as client:
rows, complete = ats._fetch_rows(client, "pinpoint:xeneta")
assert seen == ["https://xeneta.pinpointhq.com/postings.json"]
assert len(rows) == 2 and complete
def test_the_slug_the_urls_and_the_allow_list() -> None:
assert pinpoint.slug_ok("xeneta") and pinpoint.slug_ok("Xeneta") and pinpoint.slug_ok("a-b1")
assert pinpoint.careers_url("xeneta") == "https://xeneta.pinpointhq.com/"
assert pinpoint.robots_page("xeneta") == "https://xeneta.pinpointhq.com/"
assert pinpoint.feed_url("Xeneta") == "https://xeneta.pinpointhq.com/postings.json"
allow = pinpoint.allowed("Xeneta")
assert allow("xeneta.pinpointhq.com") and allow("XENETA.pinpointhq.com")
assert not allow("pinpointhq.com") and not allow("other.pinpointhq.com")
assert not allow("xeneta.pinpointhq.com.evil.example") and not allow("localhost")
assert atshosts.HOSTS["pinpoint"] is pinpoint and ats.HOSTS["pinpoint"] == "Pinpoint"
@pytest.mark.parametrize("slug", [
"", "a@b", "a#b", "a?b", "..", "a/b", "a%2fb", "a:443", "a b", " a", "a\n", "a\r\n",
"a.b", "127.0.0.1", "[::1]", "a_b", "2130706433.evil"])
def test_a_hostile_slug_is_refused(slug: str) -> None:
assert not pinpoint.slug_ok(slug)
assert not ats.is_known_target(f"pinpoint:{slug}")
@pytest.mark.parametrize("slug", ["localhost", "www"])
def test_a_slug_that_is_a_local_word_still_only_reaches_pinpoints_own_host(slug: str) -> None:
"""`localhost` is a fine DNS label, but the host it names is
`localhost.pinpointhq.com`, which is Pinpoint's."""
assert pinpoint.allowed(slug)(f"{slug}.pinpointhq.com")
assert not pinpoint.allowed(slug)(slug)
def test_discovery_finds_the_subdomain() -> None:
page = ('<a href="https://Xeneta.pinpointhq.com/en/postings/a85d5d45">Jobs</a>'
'<script src="https://www.pinpointhq.com/embed.js"></script>')
assert [(h, s) for h, s, _ in discover.boards_in(page)] == [("pinpoint", "xeneta")]
assert discover.boards_in("https://pinpointhq.com/") == []
assert "pinpoint" not in {h for h, _ in discover._UNREADABLE if h not in atshosts.HOSTS}
def test_a_pinpoint_board_is_not_probed() -> None:
assert not hasattr(pinpoint, "probe_url")