Every import, test and live doc follows the new path; behaviour is unchanged. tests/test_atshosts.py becomes tests/test_readers.py. plan-readers.md and review-ingest.md keep the old name, since they describe the state before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
115 lines
4.1 KiB
Python
115 lines
4.1 KiB
Python
"""HR Manager (Talentech): `hrmanager:<customer>`, the public RSS of a
|
|
company's job portal, paged by `skip` and `take` with no stated total.
|
|
|
|
Written from four real boards on 2026-09-29: STS Group (6 roles), Flying
|
|
Tiger and KPMG (25 or more), and NNIT (none). The feed is
|
|
`api.hr-manager.net/JobPortal.svc/<customer>/PositionList/rss/?incads=true`;
|
|
without `take` it answers the first 25 roles whatever the board holds, and
|
|
`skip` and `take` were seen to page it (25 more with `skip=25`, 100 with
|
|
`take=100`). The customer is not case-sensitive (`FLYINGTIGER` answers as
|
|
`flyingtiger` does).
|
|
|
|
robots.txt: the portal's own pages on candidate.hr-manager.net disallow
|
|
everything for `*` except the application form, and so `robots_page` is the
|
|
feed's URL, on the API host, which has no robots.txt (a 404, which allows).
|
|
The feed is the interface HR Manager publishes for readers like this one; the
|
|
portal's HTML list, which the robots.txt does shut out, is never read. The
|
|
role's link is the application form the robots.txt names as allowed, and is
|
|
only shown, not fetched.
|
|
"""
|
|
|
|
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 ._shared import Get, Page, Row, is_web_url, only, parse_dt
|
|
|
|
NAME = "hrmanager"
|
|
LABEL = "HR Manager"
|
|
PATTERNS = (
|
|
r"hr-manager\.net/vacancies/list\.aspx\?(?:[^\"'\s#<>]*?[&;])?customer=([A-Za-z0-9][A-Za-z0-9_-]*)",
|
|
r"api\.hr-manager\.net/JobPortal\.svc/([A-Za-z0-9][A-Za-z0-9_-]*)/",
|
|
)
|
|
|
|
_API = "api.hr-manager.net"
|
|
|
|
#: The roles asked for in one page. 100 were served at once at Flying Tiger; the
|
|
#: cursor moves on by what a page returned, so a smaller cap on the host's
|
|
#: side would not skip a role, and the read ends on an empty page.
|
|
PAGE_SIZE = 100
|
|
|
|
_SLUG = re.compile(r"[A-Za-z0-9][A-Za-z0-9_-]*")
|
|
|
|
|
|
def slug_ok(slug: str) -> bool:
|
|
return bool(_SLUG.fullmatch(slug))
|
|
|
|
|
|
def allowed(slug: str) -> Callable[[str], bool]:
|
|
return only(_API)
|
|
|
|
|
|
def careers_url(slug: str) -> str:
|
|
return f"https://candidate.hr-manager.net/vacancies/list.aspx?customer={slug}"
|
|
|
|
|
|
def _feed(slug: str, skip: int) -> str:
|
|
return (f"https://{_API}/JobPortal.svc/{slug}/PositionList/rss/"
|
|
f"?incads=true&skip={skip}&take={PAGE_SIZE}")
|
|
|
|
|
|
def robots_page(slug: str) -> str:
|
|
return _feed(slug, 0)
|
|
|
|
|
|
def page(get: Get, slug: str, cursor: Any) -> Page:
|
|
skip = int(cursor or 0)
|
|
items = _items(get(_feed(slug, skip), headers={"Accept": "application/rss+xml"}))
|
|
results = [{"id": item.findtext("guid") or item.findtext("link") or ""} for item in items]
|
|
return items, results, None, skip + 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]:
|
|
"""`<rss><channel><item>...`. A board with no open roles is a channel
|
|
with no items, which is an empty board; an answer without a channel is
|
|
not a feed, and raises."""
|
|
channel = ET.fromstring(body).find("channel")
|
|
if channel is None:
|
|
raise ValueError("not an HR Manager feed: no channel")
|
|
return channel.findall("item")
|
|
|
|
|
|
def rows(items: list[ET.Element], slug: str) -> list[Row]:
|
|
"""One page of items. An item has the `guid` (the position's id), `link`
|
|
(its application form), `title`, the whole advertisement as escaped HTML
|
|
in `description` and `pubDate`. It names no place, department or pay: the
|
|
place, where there is one, is in the title or the text."""
|
|
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
|
|
out.append({
|
|
"source_id": (item.findtext("guid") or url).strip(),
|
|
"title": title,
|
|
"location": "",
|
|
"url": url,
|
|
"posted": parse_dt(item.findtext("pubDate")),
|
|
"department": "",
|
|
"description": html.unescape(strip_html(item.findtext("description") or "")),
|
|
"remote": None,
|
|
"salary_text": "",
|
|
})
|
|
return out
|