From cfd5cee15a9a21438d45d92e7f4eaa8f97ca811f Mon Sep 17 00:00:00 2001
From: Airat Valiev
Date: Tue, 20 Oct 2026 00:52:32 +0200
Subject: [PATCH] feat(discovery): DACH/UK job sources and reliable board
detection
Watchlist boards (public career feeds, live-verified 2026-10-20)
- Personio XML (dominant DACH startup ATS: OroraTech, UnternehmerTUM),
Teamtailor RSS incl. custom-domain career sites (IQM), Recruitee (salary),
Workable (Hugging Face), Pinpoint (compensation when visible), Softgarden
schema.org feed. XML/RSS parsed with defusedxml (entity expansion
rejected); Teamtailor custom hosts go through the SSRF check.
Aggregators
- GermanTechJobs / SwissDevJobs / DevITjobs.uk RSS: "Role @ Company
[salary]" on every item; the feeds follow the profile's countries and are
on by default. Remote only when explicit ("remote und vor Ort" isn't).
- Salary parsing understands apostrophe separators (CHF 85'000).
Board detection
- detect_board_from_page: reads which ATS a careers page embeds (IQM ->
Teamtailor, Agile Robots -> Greenhouse); the reliable route.
- find_boards (replaces detect_board): every board answering to a name's
slugs, probed in parallel. The watchlist UI shows sample titles so the
user picks the right one: slugs collide (Lever "iqm" is an unrelated NY
company).
- Watchlist posts need only half of a target title's core terms, so
adjacent roles at companies the user chose ("Quantum Engineer") surface
for triage.
docs/JOB_SOURCES.md updated; tests cover each connector (fixtures trimmed
from real responses), the XML bomb, SSRF on custom hosts, page detection,
multi-hit name search and the watchlist threshold.
Co-Authored-By: Claude Opus 5.5
Claude-Session: https://claude.ai/code/session_01P1Ts4ix4BDwKwSBfgRphwq
---
docs/JOB_SOURCES.md | 20 +-
pyproject.toml | 1 +
services/discovery.py | 27 +-
services/profile.py | 5 +-
tests/test_phase47_dach_uk_sources.py | 268 +++++++++++++++++++
tools/html_extract.py | 14 +-
tools/job_sources.py | 371 +++++++++++++++++++++++++-
tools/url_ingest.py | 16 ++
ui/profile.py | 120 ++++++---
uv.lock | 2 +
10 files changed, 786 insertions(+), 58 deletions(-)
create mode 100644 tests/test_phase47_dach_uk_sources.py
diff --git a/docs/JOB_SOURCES.md b/docs/JOB_SOURCES.md
index c8d79ef..6ad03be 100644
--- a/docs/JOB_SOURCES.md
+++ b/docs/JOB_SOURCES.md
@@ -11,10 +11,21 @@ paste-only or go through the Chrome extension.
## Covered today (`tools/job_sources.py`)
- **Company boards (watchlist):** Greenhouse, Lever (incl. the EU host),
- Ashby, SmartRecruiters.
-- **Aggregators:** Arbeitnow, Remotive, RemoteOK, HN "Who is hiring",
- Adzuna (key).
+ Ashby, SmartRecruiters, **Personio, Teamtailor (incl. custom domains),
+ Recruitee, Workable, Pinpoint, Softgarden**.
+- **Board detection:**
+ - **From the company's careers page** (reliable): reads which ATS the
+ page embeds.
+ - **By name:** returns every board answering to the name's slugs, with
+ sample titles to confirm. A slug isn't an identity: Lever's "iqm" is an
+ unrelated New York company.
+- **Aggregators:** **GermanTechJobs / SwissDevJobs / DevITjobs.uk** (salary
+ on every item; the feeds follow your profile's countries), Arbeitnow,
+ Remotive, RemoteOK, HN "Who is hiring", Adzuna (key).
- **Open web:** Claude web search (`services.discovery.web_discover`).
+- **Watchlist title filter:** posts on your watchlist need only half of a
+ target title's core terms, so adjacent roles at companies you chose still
+ surface.
Spot-checking real DE deeptech careers pages [V] shows much of the field is
already reachable:
@@ -27,6 +38,9 @@ Personio.
## Next sources, in implementation order
+Items 1–7 shipped on 2026-10-20 (see above). Still to do: Reed, Workday, JOIN,
+and the remote-EU extras.
+
| # | Source | Endpoint | Auth | Data | Terms | Effort |
|---|---|---|---|---|---|---|
| 1 | **Personio** | `GET https://{slug}.jobs.personio.de/xml?language=en` [V] | none | full HTML description, offices, department, seniority, employment type; no salary | URL shown in Personio dev docs; robots `Allow: /` [V] | S |
diff --git a/pyproject.toml b/pyproject.toml
index b30b983..38a355b 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -14,6 +14,7 @@ dependencies = [
"bcrypt>=4.1.0",
"beautifulsoup4>=4.13.3",
"cryptography>=41.0.0",
+ "defusedxml>=0.7", # third-party XML/RSS job feeds (tools/job_sources)
"fastapi>=0.110.0",
"fpdf2>=2.8.7",
"openai>=1.65.1",
diff --git a/services/discovery.py b/services/discovery.py
index 9e8c387..f134867 100644
--- a/services/discovery.py
+++ b/services/discovery.py
@@ -43,7 +43,7 @@
logger = logging.getLogger(__name__)
-DEFAULT_SOURCES = ("watchlist", "arbeitnow", "remotive", "remoteok", "hn")
+DEFAULT_SOURCES = ("watchlist", "devjobs", "arbeitnow", "remotive", "remoteok", "hn")
TRIAGE_BATCH = 8
_DESCRIPTION_CAP = 20_000
@@ -148,7 +148,7 @@ def title_match(job_title: str, targets: Iterable[str]) -> float:
re.IGNORECASE,
)
_WORLDWIDE = re.compile(r"worldwide|anywhere|global", re.IGNORECASE)
-_MONEY_RE = re.compile(r"(\d{1,3}(?:[,.\s]\d{3})+|\d+(?:\.\d+)?)\s*([kK])?")
+_MONEY_RE = re.compile(r"(\d{1,3}(?:[,.\s'’]\d{3})+|\d+(?:\.\d+)?)\s*([kK])?")
_CURRENCIES = {"€": "EUR", "eur": "EUR", "£": "GBP", "gbp": "GBP", "$": "USD", "usd": "USD", "chf": "CHF"}
@@ -195,7 +195,7 @@ def parse_salary_max(text: str) -> Tuple[Optional[float], Optional[str]]:
currency = next((code for sym, code in _CURRENCIES.items() if sym in text.lower()), None)
values = []
for num, k in _MONEY_RE.findall(text):
- v = float(re.sub(r"[,.\s](?=\d{3}\b)", "", num).replace(",", ""))
+ v = float(re.sub(r"[,.\s'’](?=\d{3}\b)", "", num).replace(",", ""))
if k:
v *= 1000
if re.search(r"per month|/month|monthly|/mo\b", text, re.IGNORECASE):
@@ -283,6 +283,16 @@ def _adzuna_countries(profile: CandidateProfile) -> List[str]:
return list(dict.fromkeys(codes))[:3] or ["gb", "de"]
+def _devjobs_countries(profile: CandidateProfile) -> List[str]:
+ """DevJobs feeds for the profile's countries (all three when unknown, or
+ for remote-only searches, where any of them may hire remotely)."""
+ text = " ".join(profile.locations).lower()
+ codes = [c for p, c in _COUNTRY_CODES if re.search(p, text) and c in job_sources.DEVJOBS_FEEDS]
+ if not codes or profile.work_modes == ["remote"]:
+ return list(job_sources.DEVJOBS_FEEDS)
+ return list(dict.fromkeys(codes))
+
+
def _search_terms(profile: CandidateProfile) -> List[str]:
"""Target titles without seniority words, as typed ("Senior ML Engineer" -> "ML Engineer")."""
terms = [
@@ -309,6 +319,9 @@ def _source_tasks(profile: CandidateProfile, sources: Iterable[str]) -> List[Tup
tasks.append(("remoteok", job_sources.remoteok))
if "hn" in wanted:
tasks.append(("hn", job_sources.hn_whos_hiring))
+ if "devjobs" in wanted:
+ for country in _devjobs_countries(profile):
+ tasks.append((f"devjobs:{country}", partial(job_sources.devjobs, country)))
if "adzuna" in wanted and job_sources.adzuna_available():
for country in _adzuna_countries(profile):
for term in _search_terms(profile)[:2]:
@@ -337,10 +350,14 @@ def gather(profile: CandidateProfile, sources: Iterable[str]) -> Tuple[List[Tupl
def prefilter(task: str, lead: JobLead, profile: CandidateProfile, now: Optional[datetime] = None) -> bool:
if not lead.title or not lead.url:
return False
+ from_watchlist = task.split(":", 1)[0] in job_sources.BOARD_FETCHERS
targets = profile.target_titles or profile.search_keywords
- if targets and title_match(lead.title, targets) < 0.66:
+ # Companies on the watchlist were chosen deliberately, so adjacent roles
+ # there ("Quantum Engineer" for a software engineer) are worth a look:
+ # half the core title terms is enough; triage judges the actual fit.
+ threshold = 0.5 if from_watchlist else 0.66
+ if targets and title_match(lead.title, targets) < threshold:
return False
- from_watchlist = task.split(":", 1)[0] in job_sources.BOARD_FETCHERS
if not from_watchlist and lead.posted_at:
age = (now or datetime.utcnow()) - lead.posted_at
if age > timedelta(days=profile.max_posting_age_days):
diff --git a/services/profile.py b/services/profile.py
index e70eb43..3d7a2de 100644
--- a/services/profile.py
+++ b/services/profile.py
@@ -27,6 +27,7 @@
from db.models import CandidateProfile as ProfileRow
from db.session import get_session
+from tools.job_sources import BOARD_FETCHERS
from utils.llm import get_completion
from utils.security import wrap_untrusted
from utils.text import strip_code_fence
@@ -35,8 +36,8 @@
WORK_MODES = ("remote", "hybrid", "onsite")
COMPANY_STAGES = ("startup", "scale-up", "enterprise", "public sector", "non-profit")
-# Supported company-board providers for the watchlist (tools.job_sources).
-WATCHLIST_ATS = ("greenhouse", "lever", "ashby", "smartrecruiters")
+# Supported company-board providers for the watchlist.
+WATCHLIST_ATS = tuple(BOARD_FETCHERS)
class ProfileError(ValueError):
diff --git a/tests/test_phase47_dach_uk_sources.py b/tests/test_phase47_dach_uk_sources.py
new file mode 100644
index 0000000..ea6c592
--- /dev/null
+++ b/tests/test_phase47_dach_uk_sources.py
@@ -0,0 +1,268 @@
+"""DACH / UK job sources: Personio, Teamtailor, Recruitee, Workable, Pinpoint,
+Softgarden, the DevJobs RSS network, and board detection."""
+
+from __future__ import annotations
+
+import os
+import sys
+import unittest
+from unittest import mock
+
+sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
+
+
+class _Resp:
+ def __init__(self, body, status=200):
+ self._body = body
+ self.status_code = status
+ self.content = body.encode() if isinstance(body, str) else b""
+
+ def json(self):
+ return self._body
+
+
+def _routes(table):
+ def get(url, params=None, **_kw):
+ for fragment, body in table:
+ if fragment in url:
+ return body if isinstance(body, _Resp) else _Resp(body)
+ return _Resp({}, status=404)
+ return get
+
+
+def setUpModule():
+ from utils.cache import cache
+ cache.clear()
+
+
+# Trimmed from real responses (2026-10).
+PERSONIO_XML = """
+
+ 2821024OroraTech GmbHMunich
+ Remote
+ EngineeringSenior Platform Engineer (m/w/d)
+ The Mission
+ Kubernetes platform.
Python and Go.]]>
+
+ experiencedfull-time
+ 2026-09-30T08:00:00+00:00
+"""
+
+TEAMTAILOR_RSS = """
+
+IQMhttps://iqm.teamtailor.com/jobs
+- Quantum Software Engineer
+<p>Build the <strong>compiler</strong>.</p>
+Fri, 24 Jul 2026 09:05:16 +0200
+https://iqm.teamtailor.com/jobs/1-quantum-software-engineer
+hybridabc-1
+MunichGermany
+SoftwareEngineer
+
"""
+
+RECRUITEE = {"offers": [{
+ "id": 7, "title": "ML Engineer", "careers_url": "https://careers.acme.com/o/ml-engineer",
+ "company_name": "Acme", "location": "Amsterdam, Netherlands", "remote": False, "hybrid": True,
+ "published_at": "2026-10-15 09:31:36 UTC", "description": "Train models
",
+ "requirements": "",
+ "salary": {"min": 80000, "max": 100000, "currency": "EUR", "period": "year"},
+ "department": "AI",
+}]}
+
+WORKABLE = {"name": "Hugging Face", "jobs": [{
+ "title": "Open-Source ML Engineer - EMEA Remote", "shortcode": "81B4",
+ "url": "https://apply.workable.com/j/81B4", "telecommuting": True,
+ "published_on": "2026-05-29", "locations": [{"city": "Paris", "country": "France"}],
+ "description": "Transformers
", "department": "Open Source", "function": "Engineering",
+}]}
+
+PINPOINT = {"data": [{
+ "id": "559663", "title": "Backend Engineer", "url": "https://acme.pinpointhq.com/en/postings/x",
+ "description": "APIs in Go
", "key_responsibilities_header": "What you'll do",
+ "key_responsibilities": "", "workplace_type": "remote",
+ "employment_type_text": "Full Time", "location": {"city": "London", "name": "Remote"},
+ "job": {"department": {"name": "Engineering"}}, "compensation_visible": True,
+ "compensation_minimum": 70000, "compensation_maximum": 90000,
+ "compensation_currency": "GBP", "compensation_frequency": "year",
+}]}
+
+SOFTGARDEN = {"@type": "DataFeed", "dataFeedElement": [{"item": {
+ "@type": "JobPosting", "title": "Embedded Engineer (m/w/d)",
+ "url": "https://acme.career.softgarden.de/jobs/1/Embedded-Engineer/",
+ "datePosted": "2026-09-23T10:37:06.121+02:00",
+ "identifier": {"name": "Acme GmbH", "value": 1},
+ "description": "C++ on microcontrollers
",
+ "hiringOrganization": {"name": "Acme GmbH"},
+ "jobLocation": {"address": {"addressLocality": "Stuttgart", "addressCountry": "DE"}},
+}}]}
+
+DEVJOBS_RSS = """
+
+-
+https://swissdevjobs.ch/jobs/IWF-Full-Stack?utm_source=our_rss_feed
+g1Mon, 19 Oct 2026 18:12:18 GMT
+Support users remote und vor Ort.
]]>
+-
+https://germantechjobs.de/jobs/xg2Mon, 19 Oct 2026 18:12:18 GMT
+This is a 100% remote position.]]>
+"""
+
+
+class ConnectorParsingTests(unittest.TestCase):
+ def setUp(self):
+ from utils.cache import cache
+ cache.clear()
+
+ def _get(self, routes):
+ from tools import job_sources as js
+ return mock.patch.object(js.requests, "get", side_effect=_routes(routes))
+
+ def test_personio_sections_offices_and_url(self):
+ from tools import job_sources as js
+ with self._get([("jobs.personio.de/xml", _Resp(PERSONIO_XML))]):
+ [lead] = js.personio("ororatech")
+ self.assertEqual(lead.company, "OroraTech GmbH")
+ self.assertEqual(lead.location, "Munich, Remote")
+ self.assertTrue(lead.remote)
+ self.assertIn("The Mission:\nRun our Kubernetes platform.", lead.description)
+ self.assertEqual(lead.url, "https://ororatech.jobs.personio.de/job/2821024?language=en")
+
+ def test_teamtailor_namespace_fields(self):
+ from tools import job_sources as js
+ with self._get([("iqm.teamtailor.com/jobs.rss", _Resp(TEAMTAILOR_RSS))]):
+ [lead] = js.teamtailor("iqm")
+ self.assertEqual((lead.company, lead.location), ("IQM", "Munich, Germany"))
+ self.assertIn("Build the compiler.", lead.description)
+ self.assertEqual(lead.posted_at.isoformat(), "2026-07-24T07:05:16")
+ self.assertIn("hybrid", lead.tags)
+
+ def test_teamtailor_custom_host_is_ssrf_checked(self):
+ from tools import job_sources as js
+ with self.assertRaises(js.SourceError):
+ js.teamtailor("127.0.0.1")
+ with self.assertRaises(js.SourceError):
+ js.teamtailor("localhost.localdomain/../admin")
+
+ def test_recruitee_salary_and_requirements(self):
+ from tools import job_sources as js
+ with self._get([("recruitee.com/api/offers", RECRUITEE)]):
+ [lead] = js.recruitee("acme")
+ self.assertEqual(lead.salary, "EUR 80000-100000 per year")
+ self.assertIn("PyTorch", lead.description)
+ self.assertEqual(lead.posted_at.isoformat(), "2026-10-15T09:31:36")
+
+ def test_workable_remote_and_company(self):
+ from tools import job_sources as js
+ with self._get([("apply.workable.com/api/v1/widget", WORKABLE)]):
+ [lead] = js.workable("huggingface")
+ self.assertEqual((lead.company, lead.location, lead.remote), ("Hugging Face", "Paris, France", True))
+
+ def test_pinpoint_compensation_only_when_visible(self):
+ from tools import job_sources as js
+ with self._get([("pinpointhq.com/postings.json", PINPOINT)]):
+ [lead] = js.pinpoint("acme", "Acme")
+ self.assertEqual(lead.salary, "GBP 70000-90000 per year")
+ self.assertIn("What you'll do", lead.description)
+ hidden = {"data": [dict(PINPOINT["data"][0], compensation_visible=False)]}
+ from utils.cache import cache
+ cache.clear()
+ with self._get([("pinpointhq.com/postings.json", hidden)]):
+ [lead] = js.pinpoint("acme", "Acme")
+ self.assertEqual(lead.salary, "")
+
+ def test_softgarden_schema_feed(self):
+ from tools import job_sources as js
+ with self._get([("career.softgarden.de/jobs.feed.json", SOFTGARDEN)]):
+ [lead] = js.softgarden("acme")
+ self.assertEqual((lead.company, lead.location), ("Acme GmbH", "Stuttgart, DE"))
+ self.assertIn("microcontrollers", lead.description)
+
+ def test_devjobs_title_salary_and_remote(self):
+ from tools import job_sources as js
+ with self._get([("swissdevjobs.ch/rss", _Resp(DEVJOBS_RSS))]):
+ leads = js.devjobs("ch")
+ first, second = leads
+ self.assertEqual((first.title, first.company), ("Full-Stack Entwickler/in", "IWF Web Solutions AG"))
+ self.assertEqual(first.salary, "CHF 85'000 - 115'000")
+ self.assertIsNone(first.remote) # "remote und vor Ort" is not a remote job
+ self.assertTrue(second.remote)
+ self.assertEqual(first.location, "Switzerland")
+
+ def test_xml_entity_expansion_is_rejected(self):
+ from tools import job_sources as js
+ bomb = (''
+ ']>'
+ '&lol2;')
+ with self._get([("jobs.personio.de/xml", _Resp(bomb))]):
+ with self.assertRaises(js.SourceError):
+ js.personio("evil")
+
+
+class DetectionTests(unittest.TestCase):
+ def setUp(self):
+ from utils.cache import cache
+ cache.clear()
+
+ def test_careers_page_detects_embedded_board(self):
+ from tools import job_sources as js
+ page = 'Jobs'
+ with mock.patch("tools.url_ingest.fetch_html", return_value=page), \
+ mock.patch.object(js.requests, "get",
+ side_effect=_routes([("iqm.teamtailor.com/jobs.rss", _Resp(TEAMTAILOR_RSS))])):
+ self.assertEqual(js.detect_board_from_page("https://meetiqm.com/careers/"), ("teamtailor", "iqm", 1))
+
+ def test_custom_domain_teamtailor_by_marker(self):
+ from tools import job_sources as js
+ page = ''
+ with mock.patch("tools.url_ingest.fetch_html", return_value=page), \
+ mock.patch("utils.security.socket.getaddrinfo",
+ return_value=[(None, None, None, None, ("93.184.216.34", 0))]), \
+ mock.patch.object(js.requests, "get",
+ side_effect=_routes([("careers.acme.com/jobs.rss", _Resp(TEAMTAILOR_RSS))])):
+ hit = js.detect_board_from_page("https://careers.acme.com/")
+ self.assertEqual(hit[:2], ("teamtailor", "careers.acme.com"))
+
+ def test_find_boards_returns_every_hit_for_the_user_to_pick(self):
+ from tools import job_sources as js
+ routes = [("iqm.teamtailor.com/jobs.rss", _Resp(TEAMTAILOR_RSS)),
+ ("api.lever.co/v0/postings/iqm", [{"id": "1", "text": "Marketing Manager",
+ "hostedUrl": "https://jobs.lever.co/iqm/1",
+ "categories": {"location": "NY"}}])]
+ with mock.patch.object(js.requests, "get", side_effect=_routes(routes)):
+ hits = js.find_boards("IQM")
+ self.assertEqual({h[0] for h in hits}, {"teamtailor", "lever"})
+
+
+class DiscoveryWiringTests(unittest.TestCase):
+ def test_devjobs_feeds_follow_profile_countries(self):
+ from services.discovery import DEFAULT_SOURCES, _devjobs_countries
+ from services.profile import CandidateProfile
+
+ self.assertIn("devjobs", DEFAULT_SOURCES)
+ self.assertEqual(_devjobs_countries(CandidateProfile(locations=["Zurich", "Munich"])), ["de", "ch"])
+ self.assertEqual(_devjobs_countries(CandidateProfile(locations=["London"])), ["gb"])
+ self.assertEqual(sorted(_devjobs_countries(CandidateProfile(locations=["Lisbon"]))), ["ch", "de", "gb"])
+
+ def test_watchlist_boards_admit_adjacent_roles(self):
+ from datetime import datetime
+
+ from services.discovery import prefilter
+ from services.profile import CandidateProfile
+ from tools.job_sources import JobLead
+
+ profile = CandidateProfile(target_titles=["Software Engineer"])
+ quantum = JobLead(source="teamtailor", external_id="1", url="https://x/1",
+ title="Quantum Engineer, Gates", posted_at=datetime.utcnow())
+ legal = JobLead(source="teamtailor", external_id="2", url="https://x/2", title="Legal Counsel")
+ self.assertTrue(prefilter("teamtailor:IQM", quantum, profile))
+ self.assertFalse(prefilter("remotive:x", quantum, profile))
+ self.assertFalse(prefilter("teamtailor:IQM", legal, profile))
+
+ def test_watchlist_accepts_new_boards(self):
+ from services.profile import WATCHLIST_ATS
+ for ats in ("personio", "teamtailor", "recruitee", "workable", "pinpoint", "softgarden"):
+ self.assertIn(ats, WATCHLIST_ATS)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tools/html_extract.py b/tools/html_extract.py
index 3ad5ce8..c99c0cc 100644
--- a/tools/html_extract.py
+++ b/tools/html_extract.py
@@ -74,13 +74,13 @@ def _is_job_posting(node: dict) -> bool:
return "JobPosting" in kinds
-def _name(value: Any) -> str:
+def jobposting_name(value: Any) -> str:
if isinstance(value, dict):
return str(value.get("name") or "")
return str(value or "")
-def _location(node: dict) -> str:
+def jobposting_location(node: dict) -> str:
places = node.get("jobLocation") or []
places = places if isinstance(places, list) else [places]
out = []
@@ -88,7 +88,7 @@ def _location(node: dict) -> str:
addr = place.get("address") if isinstance(place, dict) else None
if isinstance(addr, dict):
parts = [
- _name(addr.get(k))
+ jobposting_name(addr.get(k))
for k in ("addressLocality", "addressRegion", "addressCountry")
]
out.append(", ".join(p for p in parts if p))
@@ -99,7 +99,7 @@ def _location(node: dict) -> str:
return "; ".join(dict.fromkeys(p for p in out if p))
-def _salary(node: dict) -> str:
+def jobposting_salary(node: dict) -> str:
base = node.get("baseSalary")
if not isinstance(base, dict):
return ""
@@ -132,10 +132,10 @@ def _job_posting_from_jsonld(soup: BeautifulSoup) -> Optional[str]:
employment = ", ".join(map(str, employment))
header = [
("Title", str(node.get("title") or "")),
- ("Company", _name(node.get("hiringOrganization"))),
- ("Location", _location(node)),
+ ("Company", jobposting_name(node.get("hiringOrganization"))),
+ ("Location", jobposting_location(node)),
("Employment type", str(employment or "")),
- ("Compensation", _salary(node)),
+ ("Compensation", jobposting_salary(node)),
("Date posted", str(node.get("datePosted") or "")),
]
lines = [f"{label}: {value}" for label, value in header if value]
diff --git a/tools/job_sources.py b/tools/job_sources.py
index 7c48dc1..5a7f4e2 100644
--- a/tools/job_sources.py
+++ b/tools/job_sources.py
@@ -9,12 +9,20 @@
* Lever api.lever.co/v0/postings/{slug} (EU tenants: api.eu.lever.co)
* Ashby api.ashbyhq.com/posting-api/job-board/{slug}
* SmartRecruiters api.smartrecruiters.com/v1/companies/{id}/postings
+ * Personio {slug}.jobs.personio.de/xml (dominant DACH startup ATS)
+ * Teamtailor {careers host}/jobs.rss (documented public feed)
+ * Recruitee {slug}.recruitee.com/api/offers/ (has salary)
+ * Workable apply.workable.com/api/v1/widget/accounts/{slug}?details=true
+ * Pinpoint {slug}.pinpointhq.com/postings.json (has compensation)
+ * Softgarden {slug}.career.softgarden.de/jobs.feed.json (schema.org feed)
+ See docs/JOB_SOURCES.md for terms and the sources deliberately not used.
Aggregators (broad; each asks for a link back, which the feed shows):
* Arbeitnow (EU, keyless) * Remotive (remote; at most a few calls a day:
cached 6h) * RemoteOK (remote; credit the source) * Hacker News
"Who is hiring?" (monthly thread, via the Algolia HN API)
* Adzuna (UK + EU countries; needs the free ADZUNA_APP_ID / ADZUNA_APP_KEY)
+ * GermanTechJobs / SwissDevJobs / DevITjobs.uk RSS (salary on every item)
Responses are cached (utils.cache), so a feed refresh doesn't hammer the APIs.
"""
@@ -26,12 +34,16 @@
import os
import re
import time
+from concurrent.futures import ThreadPoolExecutor
from dataclasses import asdict, dataclass, field
from datetime import datetime, timezone
+from email.utils import parsedate_to_datetime
from typing import Any, Callable, Dict, List, Optional, Tuple
+from urllib.parse import urlparse
import requests
from bs4 import BeautifulSoup, NavigableString, Tag
+from defusedxml import ElementTree as SafeET
from utils.cache import cache
from utils.env import env_float
@@ -96,6 +108,35 @@ def _get_json(url: str, params: Optional[dict] = None) -> Any:
raise SourceError(f"{url}: not JSON") from exc
+def _get_xml(url: str, params: Optional[dict] = None) -> Any:
+ """Fetch and parse an XML/RSS feed. Parsed with defusedxml: the feeds are
+ third-party content, so entity-expansion and external-entity tricks are
+ rejected rather than processed."""
+ try:
+ resp = requests.get(url, params=params, timeout=_TIMEOUT, headers={"User-Agent": _USER_AGENT})
+ except requests.RequestException as exc:
+ raise SourceError(f"{url}: {exc}") from exc
+ if resp.status_code >= 400:
+ raise SourceError(f"{url}: HTTP {resp.status_code}")
+ try:
+ return SafeET.fromstring(resp.content)
+ except Exception as exc: # noqa: BLE001 - ParseError / DefusedXmlException
+ raise SourceError(f"{url}: not a valid feed ({exc})") from exc
+
+
+def _xml_text(node: Any, path: str, ns: Optional[dict] = None) -> str:
+ found = node.find(path, ns) if node is not None else None
+ return (found.text or "").strip() if found is not None and found.text else ""
+
+
+def _rss_date(value: str) -> Optional[datetime]:
+ try:
+ dt = parsedate_to_datetime(value)
+ except (TypeError, ValueError):
+ return _parse_dt(value)
+ return dt.astimezone(timezone.utc).replace(tzinfo=None) if dt.tzinfo else dt
+
+
def _cached(key: str, ttl_seconds: float, fetch: Callable[[], List[JobLead]]) -> List[JobLead]:
"""Per-source response cache with its own TTL (the global cache TTL is an
upper bound). Stored as plain dicts so the Redis backend can hold it."""
@@ -308,11 +349,216 @@ def fetch() -> List[JobLead]:
return _cached(f"smartrecruiters:{company_id.lower()}", 3600, fetch)
+def personio(slug: str, company: str = "") -> List[JobLead]:
+ slug = _check_slug(slug)
+
+ def fetch() -> List[JobLead]:
+ root = _get_xml(f"https://{slug}.jobs.personio.de/xml", {"language": "en"})
+ out = []
+ for pos in root.iter("position"):
+ pid = _xml_text(pos, "id")
+ offices = [_xml_text(pos, "office")] + [
+ (o.text or "").strip() for o in pos.findall("additionalOffices/office")
+ ]
+ sections = [
+ f"{_xml_text(d, 'name')}:\n{html_to_text(_xml_text(d, 'value'))}"
+ for d in pos.findall("jobDescriptions/jobDescription")
+ ]
+ location = ", ".join(o for o in dict.fromkeys(offices) if o)
+ out.append(JobLead(
+ source="personio", external_id=pid,
+ url=f"https://{slug}.jobs.personio.de/job/{pid}?language=en",
+ title=_xml_text(pos, "name"),
+ company=_xml_text(pos, "subcompany") or company or slug,
+ location=location, remote=_looks_remote(location),
+ posted_at=_parse_dt(_xml_text(pos, "createdAt")),
+ description="\n\n".join(sections),
+ tags=[t for t in (_xml_text(pos, "department"), _xml_text(pos, "seniority"),
+ _xml_text(pos, "schedule")) if t],
+ ))
+ return out
+
+ return _cached(f"personio:{slug.lower()}", 3600, fetch)
+
+
+_HOST_RE = re.compile(r"^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+$")
+_TT_NS = {"tt": "https://teamtailor.com/locations"}
+
+
+def teamtailor(host: str, company: str = "") -> List[JobLead]:
+ """``host`` is the careers site: ``acme.teamtailor.com`` or a custom
+ domain (``careers.acme.com``); a bare slug means ``{slug}.teamtailor.com``."""
+ host = (host or "").strip().lower().removeprefix("https://").removeprefix("http://").split("/")[0]
+ if "." not in host:
+ host = f"{_check_slug(host)}.teamtailor.com"
+ if not _HOST_RE.match(host):
+ raise SourceError(f"Invalid careers host {host!r}.")
+ from utils.security import check_url_allowed
+
+ ok, reason = check_url_allowed(f"https://{host}/") # custom domains are user input
+ if not ok:
+ raise SourceError(reason)
+
+ def fetch() -> List[JobLead]:
+ out: List[JobLead] = []
+ for offset in (0, 100, 200):
+ channel = _get_xml(
+ f"https://{host}/jobs.rss", {"offset": offset, "per_page": 100}
+ ).find("channel")
+ items = channel.findall("item") if channel is not None else []
+ name = company or _xml_text(channel, "title") or host.split(".")[0]
+ for it in items:
+ places = [
+ ", ".join(p for p in (_xml_text(loc, "tt:city", _TT_NS),
+ _xml_text(loc, "tt:country", _TT_NS)) if p)
+ for loc in it.findall("tt:locations/tt:location", _TT_NS)
+ ]
+ status = _xml_text(it, "remoteStatus").lower()
+ out.append(JobLead(
+ source="teamtailor", external_id=_xml_text(it, "guid"), url=_xml_text(it, "link"),
+ title=_xml_text(it, "title"), company=name,
+ location="; ".join(p for p in places if p) or ("Remote" if status == "fully" else ""),
+ remote=True if status in ("fully", "remote") else None,
+ posted_at=_rss_date(_xml_text(it, "pubDate")),
+ description=html_to_text(_xml_text(it, "description")),
+ tags=[t for t in (_xml_text(it, "tt:department", _TT_NS),
+ _xml_text(it, "tt:role", _TT_NS), status) if t],
+ ))
+ if len(items) < 100:
+ break
+ return out
+
+ return _cached(f"teamtailor:{host}", 3600, fetch)
+
+
+def _range(lo: Any, hi: Any, currency: Any, period: Any = "") -> str:
+ if not (lo or hi):
+ return ""
+ amount = f"{lo}-{hi}" if lo and hi else str(lo or hi)
+ return " ".join(p for p in (str(currency or ""), amount, f"per {period}" if period else "") if p)
+
+
+def recruitee(slug: str, company: str = "") -> List[JobLead]:
+ slug = _check_slug(slug)
+
+ def fetch() -> List[JobLead]:
+ data = _get_json(f"https://{slug}.recruitee.com/api/offers/")
+ out = []
+ for o in data.get("offers", []):
+ sal = o.get("salary") or {}
+ out.append(JobLead(
+ source="recruitee", external_id=str(o.get("id")), url=o.get("careers_url", ""),
+ title=o.get("title", ""), company=o.get("company_name") or company or slug,
+ location=o.get("location") or ", ".join(p for p in (o.get("city"), o.get("country")) if p),
+ remote=True if o.get("remote") else None,
+ posted_at=_parse_dt(str(o.get("published_at") or "").replace(" UTC", "+00:00").replace(" ", "T", 1)),
+ salary=_range(sal.get("min"), sal.get("max"), sal.get("currency"), sal.get("period")),
+ description="\n\n".join(
+ html_to_text(o.get(k) or "") for k in ("description", "requirements") if o.get(k)
+ ),
+ tags=[t for t in (o.get("department"), "hybrid" if o.get("hybrid") else "") if t],
+ ))
+ return out
+
+ return _cached(f"recruitee:{slug.lower()}", 3600, fetch)
+
+
+def workable(slug: str, company: str = "") -> List[JobLead]:
+ slug = _check_slug(slug)
+
+ def fetch() -> List[JobLead]:
+ data = _get_json(
+ f"https://apply.workable.com/api/v1/widget/accounts/{slug}", {"details": "true"}
+ )
+ out = []
+ for j in data.get("jobs", []):
+ places = [
+ ", ".join(p for p in (loc.get("city"), loc.get("country")) if p)
+ for loc in j.get("locations") or []
+ ] or [", ".join(p for p in (j.get("city"), j.get("country")) if p)]
+ remote = j.get("telecommuting") in (True, "true", "True")
+ out.append(JobLead(
+ source="workable", external_id=str(j.get("shortcode")), url=j.get("url", ""),
+ title=j.get("title", ""), company=data.get("name") or company or slug,
+ location="; ".join(dict.fromkeys(p for p in places if p)),
+ remote=True if remote else _looks_remote(j.get("title", "")),
+ posted_at=_parse_dt(j.get("published_on") or j.get("created_at")),
+ description=html_to_text(j.get("description", "")),
+ tags=[t for t in (j.get("department"), j.get("function"), j.get("employment_type")) if t],
+ ))
+ return out
+
+ return _cached(f"workable:{slug.lower()}", 3600, fetch)
+
+
+def pinpoint(slug: str, company: str = "") -> List[JobLead]:
+ slug = _check_slug(slug)
+
+ def fetch() -> List[JobLead]:
+ data = _get_json(f"https://{slug}.pinpointhq.com/postings.json")
+ out = []
+ for j in data.get("data", []):
+ loc = j.get("location") or {}
+ workplace = str(j.get("workplace_type") or "").lower()
+ parts = [j.get("description") or ""] + [
+ f"{j.get(k + '_header') or ''}\n{j.get(k) or ''}"
+ for k in ("key_responsibilities", "skills_knowledge_expertise", "benefits") if j.get(k)
+ ]
+ out.append(JobLead(
+ source="pinpoint", external_id=str(j.get("id")), url=j.get("url", ""),
+ title=j.get("title", ""), company=company or slug,
+ location=", ".join(dict.fromkeys(p for p in (loc.get("city"), loc.get("name")) if p)),
+ remote=True if workplace == "remote" else None,
+ salary=_range(j.get("compensation_minimum"), j.get("compensation_maximum"),
+ j.get("compensation_currency"), j.get("compensation_frequency"))
+ if j.get("compensation_visible") else "",
+ description="\n\n".join(html_to_text(p) for p in parts if p.strip()),
+ tags=[t for t in (((j.get("job") or {}).get("department") or {}).get("name"),
+ j.get("employment_type_text"), workplace) if t],
+ ))
+ return out
+
+ return _cached(f"pinpoint:{slug.lower()}", 3600, fetch)
+
+
+def softgarden(slug: str, company: str = "") -> List[JobLead]:
+ from tools.html_extract import jobposting_location, jobposting_name, jobposting_salary
+
+ slug = _check_slug(slug)
+
+ def fetch() -> List[JobLead]:
+ data = _get_json(f"https://{slug}.career.softgarden.de/jobs.feed.json")
+ out = []
+ for element in data.get("dataFeedElement", []):
+ node = element.get("item") or {}
+ loc = jobposting_location(node)
+ ident = node.get("identifier") or {}
+ out.append(JobLead(
+ source="softgarden", external_id=str(ident.get("value") or node.get("url", "")),
+ url=node.get("url", ""), title=node.get("title", ""),
+ company=jobposting_name(node.get("hiringOrganization")) or str(ident.get("name") or "")
+ or company or slug,
+ location=loc, remote=_looks_remote(loc),
+ posted_at=_parse_dt(node.get("datePosted")), salary=jobposting_salary(node),
+ description=html_to_text(node.get("description", "")),
+ tags=[str(node.get("employmentType") or "")] if node.get("employmentType") else [],
+ ))
+ return out
+
+ return _cached(f"softgarden:{slug.lower()}", 3600, fetch)
+
+
BOARD_FETCHERS: Dict[str, Callable[..., List[JobLead]]] = {
"greenhouse": greenhouse,
"lever": lever,
"ashby": ashby,
"smartrecruiters": smartrecruiters,
+ "personio": personio,
+ "teamtailor": teamtailor,
+ "recruitee": recruitee,
+ "workable": workable,
+ "pinpoint": pinpoint,
+ "softgarden": softgarden,
}
@@ -324,16 +570,67 @@ def _slug_candidates(company: str) -> List[str]:
return [c for c in dict.fromkeys(cands + [camel]) if c]
-def detect_board(company: str) -> Optional[Tuple[str, str, int]]:
- """Find which public ATS board a company uses: (ats, slug, open_jobs)."""
- for slug in _slug_candidates(company):
- for ats in ("greenhouse", "lever", "ashby", "smartrecruiters"):
- try:
- jobs = BOARD_FETCHERS[ats](slug, company)
- except SourceError:
- continue
- if jobs:
- return ats, slug, len(jobs)
+def _probe(ats: str, slug: str, company: str) -> Optional[Tuple[str, str, int]]:
+ try:
+ jobs = BOARD_FETCHERS[ats](slug, company)
+ except SourceError:
+ return None
+ return (ats, slug, len(jobs)) if jobs else None
+
+
+def find_boards(company: str) -> List[Tuple[str, str, int]]:
+ """Every public ATS board answering to a company's likely slugs, probed in
+ parallel: [(ats, slug, open_jobs)], most jobs first.
+
+ A slug is not an identity: "iqm" on Lever is an unrelated New York
+ company, while IQM (quantum) is on Teamtailor. So callers must let the
+ user confirm a hit (show sample titles); ``detect_board_from_page`` on the
+ company's own careers page is the reliable route.
+ """
+ probes = [(ats, slug) for slug in _slug_candidates(company) for ats in BOARD_FETCHERS]
+ with ThreadPoolExecutor(max_workers=8) as pool:
+ hits = [h for h in pool.map(lambda p: _probe(p[0], p[1], company), probes) if h]
+ return sorted(dict.fromkeys(hits), key=lambda h: -h[2])
+
+
+# Where each ATS shows up in a careers page's HTML (links, iframes, scripts).
+_BOARD_PATTERNS: List[Tuple[str, re.Pattern]] = [
+ ("greenhouse", re.compile(r"(?:boards|job-boards)(?:\.eu)?\.greenhouse\.io/(?:embed/job_board(?:/js)?\?for=)?([A-Za-z0-9_-]+)")),
+ ("lever", re.compile(r"jobs\.(?:eu\.)?lever\.co/([A-Za-z0-9._-]+)")),
+ ("ashby", re.compile(r"jobs\.ashbyhq\.com/([A-Za-z0-9._-]+)")),
+ ("smartrecruiters", re.compile(r"(?:jobs|careers)\.smartrecruiters\.com/([A-Za-z0-9_-]+)")),
+ ("personio", re.compile(r"([a-z0-9-]+)\.jobs\.personio\.(?:de|com)")),
+ ("recruitee", re.compile(r"([a-z0-9-]+)\.recruitee\.com")),
+ ("workable", re.compile(r"apply\.workable\.com/(?!api\b|j/)([A-Za-z0-9_-]+)")),
+ ("pinpoint", re.compile(r"([a-z0-9-]+)\.pinpointhq\.com")),
+ ("softgarden", re.compile(r"([a-z0-9-]+)\.career\.softgarden\.de")),
+ ("teamtailor", re.compile(r"([a-z0-9-]+)\.teamtailor\.com")),
+]
+
+
+def detect_board_from_page(url: str, company: str = "") -> Optional[Tuple[str, str, int]]:
+ """Detect the ATS a careers page embeds, then confirm the board answers.
+ Teamtailor career sites on their own domain are recognised by the
+ platform's markers and probed at that host."""
+ from tools.url_ingest import fetch_html
+
+ try:
+ html = fetch_html(url)
+ except ValueError as exc:
+ raise SourceError(str(exc)) from exc
+ candidates: List[Tuple[str, str]] = []
+ for ats, pattern in _BOARD_PATTERNS:
+ for slug in dict.fromkeys(pattern.findall(html)):
+ if slug.lower() not in ("www", "api", "embed", "assets", "static", "cdn", "app", "careers"):
+ candidates.append((ats, slug))
+ if "teamtailor" in html.lower():
+ host = (urlparse(url).hostname or "").lower()
+ if host:
+ candidates.append(("teamtailor", host))
+ for ats, slug in dict.fromkeys(candidates):
+ hit = _probe(ats, slug, company or slug)
+ if hit:
+ return hit
return None
@@ -502,6 +799,58 @@ def fetch() -> List[JobLead]:
return _cached(f"adzuna:{country}:{what.lower()}:{where.lower()}", 3600, fetch)
+# GermanTechJobs / SwissDevJobs / DevITjobs.uk: one RSS feed per country,
+# every item titled "Role @ Company [salary]".
+DEVJOBS_FEEDS: Dict[str, Tuple[str, str]] = {
+ "de": ("https://germantechjobs.de/rss", "Germany"),
+ "ch": ("https://swissdevjobs.ch/rss", "Switzerland"),
+ "gb": ("https://devitjobs.uk/rss", "United Kingdom"),
+}
+_DEVJOBS_TITLE = re.compile(r"^(?P.*?)\s*-?\s*@\s*(?P.*?)\s*(?:\[(?P[^\]]*)\])?\s*$")
+
+
+# A bare "remote" in a description is often "support users remote and on
+# site"; only an explicit statement makes the job itself remote.
+_FULLY_REMOTE = re.compile(
+ r"(?:100\s*%|fully|full|komplett|vollständig)[\s-]*remote|remote[\s-]*(?:first|only|job|position|role)"
+ r"|work from anywhere",
+ re.IGNORECASE,
+)
+
+
+def _devjobs_remote(title: str, body: str) -> Optional[bool]:
+ return True if re.search(r"\bremote\b", title, re.IGNORECASE) or _FULLY_REMOTE.search(body) else None
+
+
+def devjobs(country: str) -> List[JobLead]:
+ country = country.lower()
+ if country not in DEVJOBS_FEEDS:
+ raise SourceError(f"No DevJobs feed for {country!r}.")
+ url, country_name = DEVJOBS_FEEDS[country]
+
+ def fetch() -> List[JobLead]:
+ channel = _get_xml(url).find("channel")
+ out = []
+ for it in channel.findall("item") if channel is not None else []:
+ raw_title = _xml_text(it, "title")
+ m = _DEVJOBS_TITLE.match(raw_title)
+ body = html_to_text(_xml_text(it, "{http://purl.org/rss/1.0/modules/content/}encoded")
+ or _xml_text(it, "description"))
+ out.append(JobLead(
+ source="devjobs", external_id=_xml_text(it, "guid") or _xml_text(it, "link"),
+ url=_xml_text(it, "link"),
+ title=(m.group("title") if m else raw_title).strip(),
+ company=(m.group("company") if m else "").strip(),
+ location=country_name, remote=_devjobs_remote(raw_title, body),
+ posted_at=_rss_date(_xml_text(it, "pubDate")),
+ salary=(m.group("salary") or "").strip() if m else "",
+ description=body,
+ ))
+ return out
+
+ return _cached(f"devjobs:{country}", 3600, fetch)
+
+
# Aggregator sources the feed can enable, with the attribution their terms ask for.
AGGREGATORS: Dict[str, dict] = {
"arbeitnow": {"label": "Arbeitnow (EU)", "credit": "arbeitnow.com"},
@@ -509,4 +858,6 @@ def fetch() -> List[JobLead]:
"remoteok": {"label": "RemoteOK (remote)", "credit": "remoteok.com"},
"hn": {"label": "HN Who is hiring", "credit": "news.ycombinator.com"},
"adzuna": {"label": "Adzuna (UK/EU, needs key)", "credit": "adzuna.com"},
+ "devjobs": {"label": "GermanTechJobs / SwissDevJobs / DevITjobs (salary)",
+ "credit": "germantechjobs.de, swissdevjobs.ch, devitjobs.uk"},
}
diff --git a/tools/url_ingest.py b/tools/url_ingest.py
index 95f5b1e..fa40e5a 100644
--- a/tools/url_ingest.py
+++ b/tools/url_ingest.py
@@ -124,6 +124,22 @@ def fetch_job_posting(url: str) -> str:
return text
+def fetch_html(url: str) -> str:
+ """A page's raw HTML through the same SSRF-checked, size-capped fetch
+ (used to detect which ATS a careers page embeds)."""
+ from utils.security import check_url_allowed
+
+ ok, reason = check_url_allowed(url)
+ if not ok:
+ raise ValueError(reason)
+ resp = _get_following_safe_redirects(url)
+ try:
+ body = _read_capped(resp)
+ finally:
+ resp.close()
+ return body.decode(resp.encoding or "utf-8", errors="replace")
+
+
_MAX_REDIRECTS = 5
diff --git a/ui/profile.py b/ui/profile.py
index 77883b9..ed48b56 100644
--- a/ui/profile.py
+++ b/ui/profile.py
@@ -153,47 +153,105 @@ def _render_watchlist(user_id: int) -> None:
st.rerun()
with st.form("watch_add_form", clear_on_submit=True):
+ careers_url = st.text_input(
+ "Careers page URL (most reliable)", placeholder="https://www.example.com/careers",
+ help="We read which job board the page embeds (Personio, Teamtailor, Greenhouse, "
+ "Lever, Ashby, Workable, Recruitee, Pinpoint, Softgarden, SmartRecruiters).",
+ )
c1, c2, c3 = st.columns([3, 2, 2])
- company = c1.text_input("Company", placeholder="N26")
+ company = c1.text_input("Company", placeholder="IQM")
ats = c2.selectbox("Board", ["auto-detect", *WATCHLIST_ATS])
- slug = c3.text_input("Board slug (optional)", placeholder="n26",
- help="The part of the jobs URL after the ATS domain, "
- "e.g. boards.greenhouse.io/**n26**.")
+ slug = c3.text_input("Board slug / host (optional)", placeholder="iqm",
+ help="The company part of the jobs URL, e.g. **iqm**.teamtailor.com "
+ "or jobs.personio.de/**acme**. For Teamtailor on a custom "
+ "domain, the host (careers.acme.com).")
if st.form_submit_button("➕ Add company"):
- _add_to_watchlist(user_id, company.strip(), ats, slug.strip())
+ _add_to_watchlist(user_id, company.strip(), ats, slug.strip(), careers_url.strip())
+ _render_board_candidates(user_id)
-def _add_to_watchlist(user_id: int, company: str, ats: str, slug: str) -> None:
- from tools.job_sources import BOARD_FETCHERS, SourceError, detect_board
- if not company:
- st.error("Enter a company name.")
- return
- if ats == "auto-detect" or not slug:
- with st.spinner(f"Looking for {company}'s job board…"):
- found = detect_board(slug or company) if ats == "auto-detect" else None
- if found is None and ats != "auto-detect":
- found = (ats, slug or company.lower().replace(" ", ""), 0)
- if found is None:
- st.warning(
- f"Couldn't find a public Greenhouse / Lever / Ashby / SmartRecruiters board "
- f"for {company}. If you know it, pick the board and enter the slug from "
- "their jobs URL; otherwise use web discovery or paste postings."
- )
- return
- ats, slug, count = found
- else:
- try:
- count = len(BOARD_FETCHERS[ats](slug, company))
- except SourceError as exc:
- st.error(f"That board didn't respond: {exc}")
- return
+def _sample_titles(ats: str, slug: str, company: str) -> str:
+ from tools.job_sources import BOARD_FETCHERS, SourceError
+
+ try:
+ leads = BOARD_FETCHERS[ats](slug, company) # cached from the probe
+ except SourceError:
+ return ""
+ return "; ".join(f"{lead.title} ({lead.location})" if lead.location else lead.title
+ for lead in leads[:3])
+
+
+def _save_watch(user_id: int, company: str, ats: str, slug: str, count: int) -> None:
profile = get_profile(user_id)
- profile.watchlist.append({"company": company, "ats": ats, "slug": slug})
+ profile.watchlist.append({"company": company or slug, "ats": ats, "slug": slug})
try:
save_profile(user_id, profile)
except ProfileError as exc:
st.error(str(exc))
return
- st.session_state["watch_msg"] = f"Watching {company} ({ats}: {slug}), {count} open roles right now."
+ st.session_state.pop("watch_candidates", None)
+ st.session_state["watch_msg"] = f"Watching {company or slug} ({ats}: {slug}), {count} open roles right now."
st.rerun()
+
+
+def _add_to_watchlist(user_id: int, company: str, ats: str, slug: str, careers_url: str) -> None:
+ from tools.job_sources import BOARD_FETCHERS, SourceError, detect_board_from_page, find_boards
+
+ if ats != "auto-detect" and slug:
+ try:
+ count = len(BOARD_FETCHERS[ats](slug, company or slug))
+ except SourceError as exc:
+ st.error(f"That board didn't respond: {exc}")
+ return
+ _save_watch(user_id, company, ats, slug, count)
+ return
+ if careers_url:
+ with st.spinner("Reading the careers page…"):
+ try:
+ found = detect_board_from_page(careers_url, company)
+ except SourceError as exc:
+ st.error(f"Couldn't read that page: {exc}")
+ return
+ if found is None:
+ st.warning(
+ "No supported job board found on that page. The company may use Workday, "
+ "JOIN or a custom system; use web discovery or paste postings for it."
+ )
+ return
+ found_ats, found_slug, count = found
+ _save_watch(user_id, company or found_slug, found_ats, found_slug, count)
+ return
+ if not company:
+ st.error("Enter a careers page URL or a company name.")
+ return
+ with st.spinner(f"Looking for {company}'s job board…"):
+ hits = find_boards(company)
+ if not hits:
+ st.warning(
+ f"No public board answers to {company!r}. Paste their careers page URL instead; "
+ "that finds boards under any name."
+ )
+ return
+ st.session_state["watch_candidates"] = [
+ {"company": company, "ats": a, "slug": sl, "count": n, "samples": _sample_titles(a, sl, company)}
+ for a, sl, n in hits
+ ]
+
+
+def _render_board_candidates(user_id: int) -> None:
+ candidates = st.session_state.get("watch_candidates") or []
+ if not candidates:
+ return
+ st.info(
+ "These boards answer to that name. A name can belong to several companies, so pick "
+ "the one whose jobs look right (or paste the careers page URL instead)."
+ )
+ for i, c in enumerate(candidates):
+ c1, c2 = st.columns([5, 1])
+ c1.markdown(f"**{c['ats']}** · `{c['slug']}` · {c['count']} jobs \n{c['samples'][:200]}")
+ if c2.button("Add", key=f"watch_pick_{i}"):
+ _save_watch(user_id, c["company"], c["ats"], c["slug"], c["count"])
+ if st.button("None of these", key="watch_pick_none"):
+ st.session_state.pop("watch_candidates", None)
+ st.rerun()
diff --git a/uv.lock b/uv.lock
index 735733b..37c3b4e 100644
--- a/uv.lock
+++ b/uv.lock
@@ -1133,6 +1133,7 @@ dependencies = [
{ name = "bcrypt" },
{ name = "beautifulsoup4" },
{ name = "cryptography" },
+ { name = "defusedxml" },
{ name = "fastapi" },
{ name = "fpdf2" },
{ name = "openai" },
@@ -1189,6 +1190,7 @@ requires-dist = [
{ name = "coverage", marker = "extra == 'dev'", specifier = ">=7.5" },
{ name = "cryptography", specifier = ">=41.0.0" },
{ name = "ddgs", marker = "extra == 'research'", specifier = ">=6.0" },
+ { name = "defusedxml", specifier = ">=0.7" },
{ name = "fastapi", specifier = ">=0.110.0" },
{ name = "fpdf2", specifier = ">=2.8.7" },
{ name = "fpdf2", marker = "extra == 'pdf'", specifier = ">=2.7.0" },