Files
jobboard/plugins/readers/teamtailor.py
T
WolfandClaude Fable 5.1 2349fc424b Require READS, search params and a dated robots record; record robots.txt per requested path
Every reader declares, so undeclared(), the scope() fallback, robots_page and
ROBOTS_ANY_CASE go. A search provider needs PARAMS and clean_params, a row may
carry company, places gains none. Each robots record names the paths the
reader requests, from robots.txt read again on 2026-09-30. Platsbanken states
remote, HR Manager states no place.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-30 15:51:13 +02:00

144 lines
5.8 KiB
Python

"""Teamtailor: `teamtailor:<subdomain>` for acme.teamtailor.com, or, for a
career site on the company's own domain, that whole host name:
`teamtailor:careers.acme.com`. An RSS feed paged by offset that states no
total.
Written from live feeds on 2026-09-29; jobhunt-hq did not read Teamtailor.
"""
from __future__ import annotations
import html
import re
import xml.etree.ElementTree as ET
from collections.abc import Callable
from typing import Any
from desk.sources import strip_html
from ._contract import Ask, Fields, Place, Reads
from ._shared import Get, Page, Row, add_place, is_web_url, only, parse_dt
NAME = "teamtailor"
LABEL = "Teamtailor"
RANK = 80
PATTERNS = (
r"https?://([a-z0-9-]+)\.teamtailor\.com",
# No slug: a career site on the company's own domain, which only loads
# Teamtailor's CDN. Discovery reads its board off the page's host.
r"cdn\.teamtailor\.com|teamtailor-cdn|teamtailor\.com/assets",
)
READS = Reads(
scope="board", listing="paged", page_size=50, text="listing", complete="end",
places="many", fields=Fields(posted="trusted", remote="stated"),
robots=("read: a career site's robots.txt disallows /app/, /messages/, /messenger/, "
"/facebook/tab/ and /jobs/internal/, so /jobs.rss is allowed (lunar, which "
"redirects to jobs.lunar.app, and careers.trackunit.com, checked 2026-09-30)"),
)
#: The 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.
PAGE_SIZE = 50
#: Only a DNS name with a letter in its last label is a site, so an address
#: (`127.0.0.1`, `[::1]`) or a single word never names a host the fetch could
#: be pointed at; `ats._get` still refuses every host but this one, redirects
#: included.
_HOST = re.compile(r"[a-z0-9-]+(\.[a-z0-9-]+)*")
#: Teamtailor's own namespace in the feed, the `tt:` of `tt:locations`.
_TT = "{https://teamtailor.com/locations}"
def site(slug: str) -> str:
"""The host a 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)."""
slug = slug.strip().lower()
return slug if "." in slug else f"{slug}.teamtailor.com"
def slug_ok(slug: str) -> bool:
host = site(slug)
return bool(slug) and slug == slug.strip() and bool(_HOST.fullmatch(host)) \
and not host.rsplit(".", 1)[-1].isdigit()
def allowed(slug: str) -> Callable[[str], bool]:
return only(site(slug))
def careers_url(slug: str) -> str:
return f"https://{site(slug)}/jobs"
def probe_url(slug: str) -> str:
return f"https://{site(slug)}/jobs.rss"
def probe_ok(body: bytes) -> bool:
return b"<item>" in body
def page(get: Get, slug: str, cursor: Any, ask: Ask = Ask()) -> Page:
offset = int(cursor or 0)
items = _items(get(f"https://{site(slug)}/jobs.rss?per_page={PAGE_SIZE}&offset={offset}"))
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
def parse(body: bytes, slug: str) -> list[Row]:
return rows(_items(body), slug)
def _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 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. `places` keeps
the distinct locations, and `location` joins them with "; ". A place is
remote or an office as far as the role's `remoteStatus` says. No pay is
stated anywhere in the feed."""
out = []
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
status = (item.findtext("remoteStatus") or "").strip()
remote = {"fully": True, "hybrid": False, "onsite": False}.get(status)
places: list[Place] = []
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()
text = city if country == city else ", ".join(p for p in (city, country) if p)
add_place(places, {"text": text, "remote": remote})
out.append({
"source_id": (item.findtext("guid") or url).strip(),
"title": title,
"places": places,
"location": "; ".join(p["text"] for p in 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": status or None,
"salary_text": "", # Teamtailor's feed states no pay at all
})
return out