Read Teamtailor career sites from their jobs.rss feed, paged by offset
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b6afe24eaa
commit
50edf0eeeb
2 files changed
+387
-33
No files matched your search
+155
-31
@@ -1,7 +1,8 @@
|
||||
"""ATS boards: Greenhouse, Lever, Ashby, Workable, SmartRecruiters, Recruitee, Personio.
|
||||
"""ATS boards: Greenhouse, Lever, Ashby, Workable, SmartRecruiters, Recruitee, Personio,
|
||||
Teamtailor.
|
||||
|
||||
Every one of these hosts is a company's own careers page speaking public,
|
||||
unauthenticated JSON (Personio: XML) — first-party, no scraping, and a role
|
||||
unauthenticated JSON (Personio, Teamtailor: XML) — first-party, no scraping, and a role
|
||||
that drops off the board is *closed*, which is the cheapest staleness check
|
||||
there is.
|
||||
|
||||
@@ -12,18 +13,25 @@ The field map and the redirect allow-list are ported from
|
||||
Recruitee and Personio are new: jobhunt-hq only read Greenhouse, Lever and
|
||||
Ashby, so those four are written from one real board of each host, fetched
|
||||
while this file was written (2026-09-23; Workable on 2026-09-28, when the
|
||||
first board with roles was seen), rather than from the Go source.
|
||||
first board with roles was seen), rather than from the Go source. Teamtailor
|
||||
is the same, written from live feeds on 2026-09-29.
|
||||
|
||||
The body cap is not a straight port — see `MAX_BYTES` below.
|
||||
|
||||
A target is `host:slug`, e.g. `greenhouse:databricks`, `ashby:deepl`,
|
||||
`lever:acme`. Every board is fetched independently; one that fails or times
|
||||
`lever:acme`, `teamtailor:acme`. Every board is fetched independently; one that fails or times
|
||||
out is logged, recorded as failing under `ats:failing:<target>` (see
|
||||
`ATSSource.fetch`), and skipped, and the rest continue.
|
||||
|
||||
Workable and SmartRecruiters page their list and state a total; every other
|
||||
host answers with the whole board at once. A paged board counts as complete
|
||||
only when it read as many distinct roles as the total says (see `_paged`).
|
||||
A Teamtailor slug is the `acme` of acme.teamtailor.com, or, for a career site
|
||||
on the company's own domain, that whole host name: `teamtailor:careers.acme.com`
|
||||
(see `_teamtailor_site`).
|
||||
|
||||
Workable and SmartRecruiters page their list and state a total; Teamtailor
|
||||
pages by offset and states none; every other host answers with the whole board
|
||||
at once. A board with a total counts as complete only when it read as many
|
||||
distinct roles as the total says, one without when it read up to an empty page
|
||||
(see `_paged`).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -36,6 +44,7 @@ import time
|
||||
import xml.etree.ElementTree as ET
|
||||
from collections.abc import Callable, Iterator
|
||||
from datetime import UTC, datetime
|
||||
from email.utils import parsedate_to_datetime
|
||||
from typing import Any
|
||||
|
||||
import httpx
|
||||
@@ -76,7 +85,8 @@ TIMEOUTS = httpx.Timeout(10.0, read=30.0)
|
||||
DEADLINE = 60.0
|
||||
|
||||
#: host -> (feed URL template, careers URL template). `{slug}` is filled in;
|
||||
#: recruitee and personio put the slug in the hostname instead of the path.
|
||||
#: recruitee and personio put the slug in the hostname instead of the path,
|
||||
#: and teamtailor's `{site}` is the whole host (see `_teamtailor_site`).
|
||||
_BOARDS: dict[str, tuple[str, str]] = {
|
||||
"greenhouse": ("https://boards-api.greenhouse.io/v1/boards/{slug}/jobs"
|
||||
"?content=true&pay_transparency=true",
|
||||
@@ -94,6 +104,7 @@ _BOARDS: dict[str, tuple[str, str]] = {
|
||||
"https://{slug}.recruitee.com"),
|
||||
"personio": ("https://{slug}.jobs.personio.de/xml",
|
||||
"https://{slug}.jobs.personio.de"),
|
||||
"teamtailor": ("https://{site}/jobs.rss", "https://{site}/jobs"),
|
||||
}
|
||||
|
||||
#: host -> the name the host gives itself: the hosts this plugin reads, in
|
||||
@@ -102,13 +113,14 @@ _BOARDS: dict[str, tuple[str, str]] = {
|
||||
HOSTS: dict[str, str] = {
|
||||
"greenhouse": "Greenhouse", "lever": "Lever", "ashby": "Ashby",
|
||||
"workable": "Workable", "smartrecruiters": "SmartRecruiters",
|
||||
"recruitee": "Recruitee", "personio": "Personio",
|
||||
"recruitee": "Recruitee", "personio": "Personio", "teamtailor": "Teamtailor",
|
||||
}
|
||||
assert set(HOSTS) == set(_BOARDS)
|
||||
|
||||
#: The hosts a request or a redirect may land on for a given board host — a
|
||||
#: fixed API host for five of them, and the company's own subdomain for the
|
||||
#: two that put the slug in the hostname. Anything else is refused, at the
|
||||
#: fixed API host for five of them, the company's own subdomain for the two
|
||||
#: that put the slug in the hostname, and the one site a Teamtailor slug names.
|
||||
#: Anything else is refused, at the
|
||||
#: first hop and at every redirect: a feed is external content, and a board
|
||||
#: row must never be able to point this fetch at an internal address.
|
||||
def _allowed_host(host: str, slug: str) -> Callable[[str], bool]:
|
||||
@@ -128,9 +140,31 @@ def _allowed_host(host: str, slug: str) -> Callable[[str], bool]:
|
||||
if host == "personio":
|
||||
want = f"{slug}.jobs.personio.de"
|
||||
return lambda h: h == want
|
||||
if host == "teamtailor":
|
||||
want = _teamtailor_site(slug)
|
||||
return lambda h: h == want
|
||||
return lambda h: False
|
||||
|
||||
|
||||
#: The host a Teamtailor career site is served from: `acme` is
|
||||
#: acme.teamtailor.com, and a slug with a dot is a site on the company's own
|
||||
#: domain, `careers.acme.com`, taken whole (the feed path is the same on both).
|
||||
#: Only a DNS name with a letter in its last label is one, so an address
|
||||
#: (`127.0.0.1`, `[::1]`) or a single word never names a host the fetch could be
|
||||
#: pointed at; `_get` still refuses every host but this one, redirects included.
|
||||
_TEAMTAILOR_HOST = re.compile(r"^[a-z0-9-]+(\.[a-z0-9-]+)*$")
|
||||
|
||||
|
||||
def _teamtailor_site(slug: str) -> str:
|
||||
slug = slug.strip().lower()
|
||||
return slug if "." in slug else f"{slug}.teamtailor.com"
|
||||
|
||||
|
||||
def _teamtailor_slug_ok(slug: str) -> bool:
|
||||
site = _teamtailor_site(slug)
|
||||
return bool(_TEAMTAILOR_HOST.match(site)) and not site.rsplit(".", 1)[-1].isdigit()
|
||||
|
||||
|
||||
def _is_web_url(url: str) -> bool:
|
||||
"""A trimmed http(s) URL, or refuse — a feed is external content and a
|
||||
`javascript:` or `data:` link must never reach an href. Port of
|
||||
@@ -200,8 +234,8 @@ def _get(client: httpx.Client, url: str, host: str, slug: str, *,
|
||||
|
||||
def _parse_dt(value: Any) -> datetime | None:
|
||||
"""An aware datetime from whatever a board sends: ISO-8601 with an
|
||||
offset, `Z`, a bare date, epoch milliseconds, or "YYYY-MM-DD HH:MM:SS
|
||||
UTC". None for anything else, which `Item` reads as "now"."""
|
||||
offset, `Z`, a bare date, epoch milliseconds, "YYYY-MM-DD HH:MM:SS UTC",
|
||||
or an RSS date ("Tue, 29 Sep 2026 13:36:59 +0200"). None for anything else, which `Item` reads as "now"."""
|
||||
if value is None:
|
||||
return None
|
||||
if isinstance(value, int | float):
|
||||
@@ -217,7 +251,11 @@ def _parse_dt(value: Any) -> datetime | None:
|
||||
except ValueError:
|
||||
match = re.match(r"^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2}:\d{2})", text)
|
||||
if not match:
|
||||
return None
|
||||
try:
|
||||
parsed = parsedate_to_datetime(text)
|
||||
except (TypeError, ValueError):
|
||||
return None
|
||||
return parsed if parsed.utcoffset() is not None else parsed.replace(tzinfo=UTC)
|
||||
parsed = datetime.fromisoformat(f"{match.group(1)}T{match.group(2)}+00:00")
|
||||
return parsed if parsed.utcoffset() is not None else parsed.replace(tzinfo=UTC)
|
||||
|
||||
@@ -234,7 +272,7 @@ Row = dict[str, Any]
|
||||
# (integers) and `currency` (ISO 4217) — the columns `upsert_role` unpacks
|
||||
# `raw` into, per docs/decisions.md's "raw is transport, columns are
|
||||
# storage". Only Ashby, Greenhouse, Lever, Recruitee and Personio give
|
||||
# structured pay on their list endpoint; Workable and SmartRecruiters do not
|
||||
# structured pay on their list endpoint; Workable, SmartRecruiters and Teamtailor do not
|
||||
# (checked live, 2026-09-29), so their parsers are untouched and `row.get`
|
||||
# below reads a plain '' or None for them.
|
||||
|
||||
@@ -684,8 +722,67 @@ def _parse_personio(body: bytes, slug: str) -> list[Row]:
|
||||
return rows
|
||||
|
||||
|
||||
#: Teamtailor's own namespace in the feed, the `tt:` of `tt:locations`.
|
||||
_TT = "{https://teamtailor.com/locations}"
|
||||
|
||||
#: Teamtailor's `remoteStatus` -> `store._remote`'s words. `none` says nothing
|
||||
#: about where the role is worked and `temporary` is remote for a spell only,
|
||||
#: so both stay unknown rather than become "onsite" or "remote".
|
||||
_TEAMTAILOR_REMOTE = {"fully": "remote", "hybrid": "hybrid", "onsite": "onsite"}
|
||||
|
||||
|
||||
def _parse_teamtailor(body: bytes, slug: str) -> list[Row]:
|
||||
return _teamtailor_rows(_teamtailor_items(body), slug)
|
||||
|
||||
|
||||
def _teamtailor_items(body: bytes) -> list[ET.Element]:
|
||||
"""`{site}/jobs.rss` -> `<rss><channel><item>...`, the feed every Teamtailor
|
||||
career site serves (checked live on a dozen sites, 2026-09-29). A missing
|
||||
`channel` is a page that is not a feed, and raises."""
|
||||
channel = ET.fromstring(body).find("channel")
|
||||
if channel is None:
|
||||
raise ValueError("not a Teamtailor feed: no channel")
|
||||
return channel.findall("item")
|
||||
|
||||
|
||||
def _teamtailor_rows(items: list[ET.Element], slug: str) -> list[Row]:
|
||||
"""One page of items. The item has the title, the job URL (on the site's
|
||||
own domain), a `guid` uuid, `pubDate`, the HTML `description` in full,
|
||||
`remoteStatus` (fully, hybrid, onsite, none or temporary), and, in the
|
||||
`tt:` namespace, `locations` (a list: `city` and `country` each, `name` free
|
||||
text), `department` and `role`, either of which may be empty. `place` joins
|
||||
the distinct locations with "; ", which `country_of` reads a location at a
|
||||
time. No pay is stated anywhere in the feed."""
|
||||
rows = []
|
||||
for item in items:
|
||||
title = (item.findtext("title") or "").strip()
|
||||
url = (item.findtext("link") or "").strip()
|
||||
if not title or not _is_web_url(url):
|
||||
continue
|
||||
places: list[str] = []
|
||||
for loc in item.findall(f"{_TT}locations/{_TT}location"):
|
||||
city = (loc.findtext(f"{_TT}city") or loc.findtext(f"{_TT}name") or "").strip()
|
||||
country = (loc.findtext(f"{_TT}country") or "").strip()
|
||||
place = city if country == city else ", ".join(p for p in (city, country) if p)
|
||||
if place and place not in places:
|
||||
places.append(place)
|
||||
rows.append({
|
||||
"source_id": (item.findtext("guid") or url).strip(),
|
||||
"title": title,
|
||||
"location": "; ".join(places),
|
||||
"url": url,
|
||||
"posted": _parse_dt(item.findtext("pubDate")),
|
||||
"department": ((item.findtext(f"{_TT}department") or "").strip()
|
||||
or (item.findtext(f"{_TT}role") or "").strip()),
|
||||
"description": html.unescape(strip_html(item.findtext("description") or "")),
|
||||
"remote": _TEAMTAILOR_REMOTE.get((item.findtext("remoteStatus") or "").strip()),
|
||||
"salary_text": "", # Teamtailor's feed states no pay at all
|
||||
})
|
||||
return rows
|
||||
|
||||
|
||||
#: host -> parser. Every one takes the raw response body, plus the slug for
|
||||
#: the two hosts whose feed does not carry the URL or the company itself.
|
||||
#: the hosts whose feed does not carry the URL or the company itself.
|
||||
_PARSERS: dict[str, Callable[..., list[Row]]] = {
|
||||
"greenhouse": lambda body, slug: _parse_greenhouse(body),
|
||||
"lever": lambda body, slug: _parse_lever(body),
|
||||
@@ -694,6 +791,7 @@ _PARSERS: dict[str, Callable[..., list[Row]]] = {
|
||||
"smartrecruiters": _parse_smartrecruiters,
|
||||
"recruitee": lambda body, slug: _parse_recruitee(body),
|
||||
"personio": _parse_personio,
|
||||
"teamtailor": _parse_teamtailor,
|
||||
}
|
||||
|
||||
|
||||
@@ -825,11 +923,13 @@ def classify(department: str, title: str) -> str:
|
||||
|
||||
|
||||
def is_known_target(target: str) -> bool:
|
||||
"""`host:slug`, with `host` one of `_BOARDS` and a non-empty slug. What
|
||||
"""`host:slug`, with `host` one of `_BOARDS` and a non-empty slug (for
|
||||
Teamtailor one that names a host, see `_teamtailor_slug_ok`). What
|
||||
the target validator refuses: `app companies add` and the pull job
|
||||
both call this before touching the network."""
|
||||
host, sep, slug = target.partition(":")
|
||||
return bool(sep) and host in _BOARDS and bool(slug.strip())
|
||||
return (bool(sep) and host in _BOARDS and bool(slug.strip())
|
||||
and (host != "teamtailor" or _teamtailor_slug_ok(slug)))
|
||||
|
||||
|
||||
def careers_url(target: str) -> str:
|
||||
@@ -838,12 +938,12 @@ def careers_url(target: str) -> str:
|
||||
host, _, slug = target.partition(":")
|
||||
if host not in _BOARDS:
|
||||
return ""
|
||||
return _BOARDS[host][1].format(slug=slug)
|
||||
return _BOARDS[host][1].format(slug=slug, site=_teamtailor_site(slug))
|
||||
|
||||
|
||||
#: Pages read from one paged board at most, and the pause between two of
|
||||
#: them. Workable answers ten roles a page and SmartRecruiters a hundred, so
|
||||
#: the cap is 1,000 and 10,000 roles; the pause keeps Workable, which answers
|
||||
#: them. Workable answers ten roles a page, SmartRecruiters a hundred and
|
||||
#: Teamtailor fifty, so the cap is 1,000, 10,000 and 5,000 roles; the pause keeps Workable, which answers
|
||||
#: a burst with 429, from seeing one.
|
||||
MAX_PAGES = 100
|
||||
PAGE_DELAY = 0.5
|
||||
@@ -851,9 +951,17 @@ PAGE_DELAY = 0.5
|
||||
#: SmartRecruiters' page size, which is also the most it serves per page.
|
||||
SMARTRECRUITERS_PAGE = 100
|
||||
|
||||
#: Teamtailor's page size, asked for as `per_page`. A feed with neither
|
||||
#: parameter answers with every role (73 of 73 at Shine, 2026-09-29), but says
|
||||
#: nowhere that it is the whole list, so this reads by page to an empty one;
|
||||
#: `per_page=200` was answered in full too, and the cursor advances by what a
|
||||
#: page returned, so a smaller cap on the host's side would not skip a role.
|
||||
TEAMTAILOR_PAGE = 50
|
||||
|
||||
#: A paged host's one page: `(client, slug, cursor)` -> the decoded page, its
|
||||
#: raw results, the total it states, and the cursor of the next page (None
|
||||
#: after the last). The first call gets cursor None.
|
||||
#: raw results, the total it states (None for a host that states none), and the
|
||||
#: cursor of the next page (None after the last). The first call gets cursor
|
||||
#: None.
|
||||
Page = tuple[dict[str, Any], list[dict[str, Any]], Any, Any]
|
||||
|
||||
|
||||
@@ -873,19 +981,32 @@ def _smartrecruiters_page(client: httpx.Client, slug: str, cursor: Any) -> Page:
|
||||
return data, content, data.get("totalFound"), offset + len(content) if content else None
|
||||
|
||||
|
||||
def _teamtailor_page(client: httpx.Client, slug: str, cursor: Any) -> Page:
|
||||
offset = int(cursor or 0)
|
||||
url = (_BOARDS["teamtailor"][0].format(site=_teamtailor_site(slug))
|
||||
+ f"?per_page={TEAMTAILOR_PAGE}&offset={offset}")
|
||||
items = _teamtailor_items(_get(client, url, "teamtailor", slug))
|
||||
results = [{"id": item.findtext("guid") or item.findtext("link") or ""} for item in items]
|
||||
return items, results, None, offset + len(items) if items else None
|
||||
|
||||
|
||||
#: host -> (one page, that page's rows) for the hosts that page.
|
||||
_PAGED: dict[str, tuple[Callable[[httpx.Client, str, Any], Page],
|
||||
Callable[[dict[str, Any], str], list[Row]]]] = {
|
||||
"workable": (_workable_page, _workable_rows),
|
||||
"smartrecruiters": (_smartrecruiters_page, _smartrecruiters_rows),
|
||||
"teamtailor": (_teamtailor_page, _teamtailor_rows),
|
||||
}
|
||||
|
||||
|
||||
def _paged(client: httpx.Client, target: str) -> tuple[list[Row], bool]:
|
||||
"""Every page of a Workable or SmartRecruiters board, `PAGE_DELAY` apart,
|
||||
until the host has no next page, the stated total is reached, or
|
||||
`MAX_PAGES`. Returns the rows and whether the board is complete: as many
|
||||
distinct results read as the host's stated total. Counted on the raw
|
||||
"""Every page of a Workable, SmartRecruiters or Teamtailor board,
|
||||
`PAGE_DELAY` apart, until the host has no next page, the stated total is
|
||||
reached, or `MAX_PAGES`. Returns the rows and whether the board is
|
||||
complete: as many distinct results read as the host's stated total, or,
|
||||
for a host that states none (Teamtailor), the read ended on an empty page
|
||||
(a page with nothing new in it ends the read short of that, incomplete,
|
||||
so an offset the host ignores cannot loop). Counted on the raw
|
||||
results, so a row the parser drops does not make a board incomplete, and
|
||||
on distinct ids, so a page that shifted under an offset and repeated a
|
||||
role does not make it complete.
|
||||
@@ -909,14 +1030,17 @@ def _paged(client: httpx.Client, target: str) -> tuple[list[Row], bool]:
|
||||
log.warning("ats: %s: 429 on page %d; kept %d of %s, not complete",
|
||||
target, page + 1, len(seen), total)
|
||||
return list(rows.values()), False
|
||||
before = len(seen)
|
||||
seen |= {str(r.get("id") or r.get("shortcode") or "") for r in results}
|
||||
for row in rows_of(data, slug):
|
||||
rows.setdefault(row["source_id"], row)
|
||||
if cursor is None or (isinstance(total, int) and len(seen) >= total):
|
||||
if (cursor is None or (isinstance(total, int) and len(seen) >= total)
|
||||
or (total is None and len(seen) == before)):
|
||||
break
|
||||
complete = isinstance(total, int) and len(seen) == total
|
||||
complete = len(seen) == total if isinstance(total, int) else total is None and cursor is None
|
||||
if not complete:
|
||||
log.warning("ats: %s: read %d of %s stated; not complete", target, len(seen), total)
|
||||
log.warning("ats: %s: read %d of %s stated; not complete", target, len(seen),
|
||||
"an unstated total" if total is None else total)
|
||||
return list(rows.values()), complete
|
||||
|
||||
|
||||
@@ -972,7 +1096,7 @@ def failure_reason(exc: BaseException) -> str:
|
||||
class ATSSource(Source):
|
||||
name = "ats"
|
||||
description = "Company job boards: Greenhouse, Lever, Ashby, Workable, " \
|
||||
"SmartRecruiters, Recruitee, Personio."
|
||||
"SmartRecruiters, Recruitee, Personio, Teamtailor."
|
||||
#: The raw entries under `sources.ats.boards` are `{"url": target, "label":
|
||||
#: company}` — `url` carries the `host:slug` target and `label` the
|
||||
#: company name, which is how `Source.targets()`'s generic dict reading
|
||||
|
||||
Reference in new issue
Block a user