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>
126 lines
4.7 KiB
Python
126 lines
4.7 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. The feed is on the API host,
|
|
which has no robots.txt (a 404, which allows); it is the interface HR Manager
|
|
publishes for readers like this one, and 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.
|
|
`READS.robots` records both hosts and the owner's decision.
|
|
|
|
The feed names no place (the title or the text may), so every row has
|
|
`places == []` (`places="none"`).
|
|
"""
|
|
|
|
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, Reads, Row
|
|
from ._shared import Get, Page, is_web_url, only, parse_dt
|
|
|
|
READS = Reads(
|
|
scope="board", listing="paged", page_size=100, text="listing", complete="end",
|
|
places="none",
|
|
fields=Fields(posted="listed"),
|
|
robots=("read: the feed /JobPortal.svc/<customer>/PositionList/rss/ is on "
|
|
"api.hr-manager.net, whose /robots.txt answers 404 (checked 2026-09-30); the portal "
|
|
"candidate.hr-manager.net disallows all but /ApplicationInit.aspx? and is not "
|
|
"read: owner, 2026-09-29"),
|
|
)
|
|
|
|
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 page(get: Get, slug: str, cursor: Any, ask: Ask) -> 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,
|
|
"places": [],
|
|
"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
|