Spaces:
Sleeping
Careers-page scraping infrastructure (Greenhouse/Lever/Workday/SR/Personio)
Browse filesUser asked to add direct careers-page scraping for Curium clients.
Built the infrastructure as an additive fourth jobs-source phase
after Adzuna and the keyword scraper.
careers_scraper.py — five public-API fetchers:
- Greenhouse (boards-api.greenhouse.io)
- Lever (api.lever.co)
- Workday (*.myworkdayjobs.com — POST search endpoint)
- SmartRecruiters (api.smartrecruiters.com)
- Personio XML feed
Auto-dispatches to the right fetcher based on URL pattern. Filters
to senior + transformation/change/people titles only. Each posting
gets the client name attached so it lands in the right collator
company record.
hunter._hunt_jobs_fast: new Phase 1c calls
careers_scraper.run_all_client_careers — walks every curium_clients
entry that has an `ats_url` set, fetches that client's senior
roles, adds to the same all_jobs pool that Adzuna fills. Same
US-signal filter applies (with UK/EMEA carve-out).
scripts/discover_ats.py — probes each client name across all 5
ATS platforms with sensible slug variants. Reports findings as
copy-paste config snippets. Run output is NOT auto-applied;
admin reviews and copies into config.yaml manually.
Discovery run against the 19 current Curium clients: 0 genuine
matches. The 2 superficial slug matches were both false positives
(German Bentley, Argentine Jaguar). All 19 use bespoke careers
sites, so this phase will be a no-op for them today — but the
infrastructure is ready for future clients on public-API ATS.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- careers_scraper.py +335 -0
- hunter.py +29 -3
- scripts/discover_ats.py +232 -0
|
@@ -0,0 +1,335 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Careers-page scraper for Curium clients.
|
| 3 |
+
|
| 4 |
+
Most modern enterprises post jobs to one of four hosted ATS platforms,
|
| 5 |
+
each of which exposes a public JSON API (no auth, no scraping). This
|
| 6 |
+
module hits those APIs directly for any Curium client whose `ats_url`
|
| 7 |
+
is configured in config.yaml.
|
| 8 |
+
|
| 9 |
+
Catches senior strategic hires that companies post to their own careers
|
| 10 |
+
page first, before they syndicate (or never syndicate) to Adzuna /
|
| 11 |
+
Indeed / Reed.
|
| 12 |
+
|
| 13 |
+
Supported ATS platforms:
|
| 14 |
+
- Greenhouse (boards-api.greenhouse.io)
|
| 15 |
+
- Lever (api.lever.co)
|
| 16 |
+
- Workday (*.myworkdayjobs.com — public job search endpoint)
|
| 17 |
+
- SmartRecruiters (api.smartrecruiters.com)
|
| 18 |
+
- Personio (*.jobs.personio.com — XML feed)
|
| 19 |
+
|
| 20 |
+
Config (in config.yaml under each curium_clients entry):
|
| 21 |
+
- name: "Premier Foods"
|
| 22 |
+
sector: "food_beverage"
|
| 23 |
+
status: "current"
|
| 24 |
+
service_lines: ["TD"]
|
| 25 |
+
ats_url: "https://boards-api.greenhouse.io/v1/boards/premierfoods/jobs"
|
| 26 |
+
|
| 27 |
+
If `ats_url` is missing the client is skipped. Use scripts/discover_ats.py
|
| 28 |
+
to probe a client's most likely ATS URLs.
|
| 29 |
+
"""
|
| 30 |
+
|
| 31 |
+
from __future__ import annotations
|
| 32 |
+
|
| 33 |
+
import re
|
| 34 |
+
from typing import Callable, Optional
|
| 35 |
+
|
| 36 |
+
import requests
|
| 37 |
+
import yaml
|
| 38 |
+
|
| 39 |
+
from pathlib import Path
|
| 40 |
+
|
| 41 |
+
CONFIG_PATH = Path(__file__).parent / "config.yaml"
|
| 42 |
+
|
| 43 |
+
# Senior + transformation-relevant title keywords (mirrors the Adzuna
|
| 44 |
+
# filter — keeps the digest noise low).
|
| 45 |
+
SENIOR_TITLE_TOKENS = [
|
| 46 |
+
"head of", "director of", "director,",
|
| 47 |
+
"chief", "vp ", "vice president",
|
| 48 |
+
"programme director", "programme manager",
|
| 49 |
+
"transformation director", "transformation manager",
|
| 50 |
+
"change director", "change lead",
|
| 51 |
+
]
|
| 52 |
+
RELEVANT_FUNCTION_TOKENS = [
|
| 53 |
+
"transformation", "change", "people", "talent", "culture",
|
| 54 |
+
"operating model", "programme", "pmo", "tmo",
|
| 55 |
+
"learning", "development", "l&d",
|
| 56 |
+
"operations", "modernisation", "modernization",
|
| 57 |
+
"leadership", "ceo", "cfo", "coo", "cpo", "cto", "cio",
|
| 58 |
+
"hr", "human resources", "wellbeing",
|
| 59 |
+
"digital", "ai ", "data",
|
| 60 |
+
"customer", "experience",
|
| 61 |
+
"finance", "commercial",
|
| 62 |
+
]
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
def _is_relevant_title(title: str) -> bool:
|
| 66 |
+
if not title:
|
| 67 |
+
return False
|
| 68 |
+
t = title.lower()
|
| 69 |
+
has_seniority = any(p in t for p in SENIOR_TITLE_TOKENS)
|
| 70 |
+
has_function = any(k in t for k in RELEVANT_FUNCTION_TOKENS)
|
| 71 |
+
return has_seniority and has_function
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
def _strip_html(s: str) -> str:
|
| 75 |
+
if not s:
|
| 76 |
+
return ""
|
| 77 |
+
return re.sub(r"<[^>]+>", " ", s).replace("&", "&").replace(" ", " ").strip()
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
def detect_ats(url: str) -> Optional[str]:
|
| 81 |
+
"""Identify which ATS a URL belongs to."""
|
| 82 |
+
if not url:
|
| 83 |
+
return None
|
| 84 |
+
u = url.lower()
|
| 85 |
+
if "greenhouse" in u:
|
| 86 |
+
return "greenhouse"
|
| 87 |
+
if "lever.co" in u:
|
| 88 |
+
return "lever"
|
| 89 |
+
if "myworkdayjobs.com" in u or ".wd" in u and "myworkday" in u:
|
| 90 |
+
return "workday"
|
| 91 |
+
if "smartrecruiters" in u:
|
| 92 |
+
return "smartrecruiters"
|
| 93 |
+
if "personio.com" in u or "personio.de" in u:
|
| 94 |
+
return "personio"
|
| 95 |
+
return None
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
# =============================================================================
|
| 99 |
+
# Per-ATS fetchers
|
| 100 |
+
# =============================================================================
|
| 101 |
+
|
| 102 |
+
def fetch_greenhouse(url: str, timeout: int = 15) -> list[dict]:
|
| 103 |
+
"""Greenhouse Boards API. URL form:
|
| 104 |
+
https://boards-api.greenhouse.io/v1/boards/<TOKEN>/jobs"""
|
| 105 |
+
if "?" not in url:
|
| 106 |
+
url = url + "?content=true"
|
| 107 |
+
try:
|
| 108 |
+
r = requests.get(url, timeout=timeout)
|
| 109 |
+
r.raise_for_status()
|
| 110 |
+
data = r.json()
|
| 111 |
+
except Exception:
|
| 112 |
+
return []
|
| 113 |
+
out = []
|
| 114 |
+
for j in data.get("jobs", []) or []:
|
| 115 |
+
title = (j.get("title") or "").strip()
|
| 116 |
+
if not title:
|
| 117 |
+
continue
|
| 118 |
+
loc = (j.get("location") or {}).get("name", "")
|
| 119 |
+
desc = _strip_html(j.get("content") or "")[:1500]
|
| 120 |
+
out.append({
|
| 121 |
+
"title": title,
|
| 122 |
+
"link": j.get("absolute_url") or "",
|
| 123 |
+
"description": desc,
|
| 124 |
+
"location": loc,
|
| 125 |
+
"posted_date": j.get("updated_at") or j.get("created_at") or "",
|
| 126 |
+
"_source_board": "greenhouse",
|
| 127 |
+
})
|
| 128 |
+
return out
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
def fetch_lever(url: str, timeout: int = 15) -> list[dict]:
|
| 132 |
+
"""Lever public postings API. URL form:
|
| 133 |
+
https://api.lever.co/v0/postings/<SLUG>?mode=json"""
|
| 134 |
+
if "mode=" not in url:
|
| 135 |
+
url = url + ("&" if "?" in url else "?") + "mode=json"
|
| 136 |
+
try:
|
| 137 |
+
r = requests.get(url, timeout=timeout)
|
| 138 |
+
r.raise_for_status()
|
| 139 |
+
data = r.json()
|
| 140 |
+
except Exception:
|
| 141 |
+
return []
|
| 142 |
+
out = []
|
| 143 |
+
for j in data or []:
|
| 144 |
+
title = (j.get("text") or "").strip()
|
| 145 |
+
if not title:
|
| 146 |
+
continue
|
| 147 |
+
cats = j.get("categories") or {}
|
| 148 |
+
loc = cats.get("location") or ""
|
| 149 |
+
desc = (j.get("descriptionPlain") or "")[:1500]
|
| 150 |
+
out.append({
|
| 151 |
+
"title": title,
|
| 152 |
+
"link": j.get("hostedUrl") or "",
|
| 153 |
+
"description": desc,
|
| 154 |
+
"location": loc,
|
| 155 |
+
"posted_date": j.get("createdAt") or "",
|
| 156 |
+
"_source_board": "lever",
|
| 157 |
+
})
|
| 158 |
+
return out
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
def fetch_workday(url: str, timeout: int = 20) -> list[dict]:
|
| 162 |
+
"""Workday public job search. URL form:
|
| 163 |
+
https://<tenant>.wd1.myworkdayjobs.com/wday/cxs/<tenant>/<site>/jobs
|
| 164 |
+
|
| 165 |
+
Workday wants a POST with body {limit, offset, searchText, ...}.
|
| 166 |
+
Returns at most 50 per page; we hit one page (most companies have
|
| 167 |
+
hundreds of roles globally — we want the 50 most recent)."""
|
| 168 |
+
if not url.endswith("/jobs"):
|
| 169 |
+
# Allow the user to pass the careers-page URL and we'll construct
|
| 170 |
+
# the API endpoint. Common pattern:
|
| 171 |
+
# https://<tenant>.wd1.myworkdayjobs.com/<site>
|
| 172 |
+
# → https://<tenant>.wd1.myworkdayjobs.com/wday/cxs/<tenant>/<site>/jobs
|
| 173 |
+
m = re.match(r"https://([^/]+\.myworkdayjobs\.com)/(?:en-US/)?([^/?#]+)", url)
|
| 174 |
+
if m:
|
| 175 |
+
host, site = m.group(1), m.group(2)
|
| 176 |
+
tenant = host.split(".")[0]
|
| 177 |
+
url = f"https://{host}/wday/cxs/{tenant}/{site}/jobs"
|
| 178 |
+
|
| 179 |
+
try:
|
| 180 |
+
r = requests.post(
|
| 181 |
+
url,
|
| 182 |
+
headers={
|
| 183 |
+
"Content-Type": "application/json",
|
| 184 |
+
"Accept": "application/json",
|
| 185 |
+
},
|
| 186 |
+
json={"limit": 50, "offset": 0, "searchText": ""},
|
| 187 |
+
timeout=timeout,
|
| 188 |
+
)
|
| 189 |
+
r.raise_for_status()
|
| 190 |
+
data = r.json()
|
| 191 |
+
except Exception:
|
| 192 |
+
return []
|
| 193 |
+
out = []
|
| 194 |
+
base_host = re.match(r"https?://([^/]+)/", url)
|
| 195 |
+
base_host = base_host.group(1) if base_host else ""
|
| 196 |
+
for posting in data.get("jobPostings", []) or []:
|
| 197 |
+
title = (posting.get("title") or "").strip()
|
| 198 |
+
if not title:
|
| 199 |
+
continue
|
| 200 |
+
loc = posting.get("locationsText", "")
|
| 201 |
+
path = posting.get("externalPath", "")
|
| 202 |
+
link = f"https://{base_host}{path}" if base_host else path
|
| 203 |
+
out.append({
|
| 204 |
+
"title": title,
|
| 205 |
+
"link": link,
|
| 206 |
+
"description": "",
|
| 207 |
+
"location": loc,
|
| 208 |
+
"posted_date": posting.get("postedOn") or "",
|
| 209 |
+
"_source_board": "workday",
|
| 210 |
+
})
|
| 211 |
+
return out
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
def fetch_smartrecruiters(url: str, timeout: int = 15) -> list[dict]:
|
| 215 |
+
"""SmartRecruiters public postings. URL form:
|
| 216 |
+
https://api.smartrecruiters.com/v1/companies/<COMPANY>/postings"""
|
| 217 |
+
try:
|
| 218 |
+
r = requests.get(url, params={"limit": 100}, timeout=timeout)
|
| 219 |
+
r.raise_for_status()
|
| 220 |
+
data = r.json()
|
| 221 |
+
except Exception:
|
| 222 |
+
return []
|
| 223 |
+
out = []
|
| 224 |
+
for p in data.get("content", []) or []:
|
| 225 |
+
title = (p.get("name") or "").strip()
|
| 226 |
+
if not title:
|
| 227 |
+
continue
|
| 228 |
+
loc_obj = (p.get("location") or {})
|
| 229 |
+
loc = ", ".join(filter(None, [loc_obj.get("city"), loc_obj.get("country")]))
|
| 230 |
+
out.append({
|
| 231 |
+
"title": title,
|
| 232 |
+
"link": (p.get("ref") or p.get("postingUrl") or ""),
|
| 233 |
+
"description": "",
|
| 234 |
+
"location": loc,
|
| 235 |
+
"posted_date": p.get("releasedDate") or p.get("createdOn") or "",
|
| 236 |
+
"_source_board": "smartrecruiters",
|
| 237 |
+
})
|
| 238 |
+
return out
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
def fetch_personio(url: str, timeout: int = 15) -> list[dict]:
|
| 242 |
+
"""Personio XML feed. URL form:
|
| 243 |
+
https://<company>.jobs.personio.com/xml or .de/xml"""
|
| 244 |
+
try:
|
| 245 |
+
r = requests.get(url, timeout=timeout)
|
| 246 |
+
r.raise_for_status()
|
| 247 |
+
# Use feedparser to parse Personio's XML — it accepts multi-format
|
| 248 |
+
import feedparser
|
| 249 |
+
feed = feedparser.parse(r.content)
|
| 250 |
+
except Exception:
|
| 251 |
+
return []
|
| 252 |
+
out = []
|
| 253 |
+
for e in (feed.entries or []):
|
| 254 |
+
title = (getattr(e, "title", "") or "").strip()
|
| 255 |
+
if not title:
|
| 256 |
+
continue
|
| 257 |
+
link = getattr(e, "link", "") or ""
|
| 258 |
+
loc = getattr(e, "office", "") or getattr(e, "department", "") or ""
|
| 259 |
+
out.append({
|
| 260 |
+
"title": title,
|
| 261 |
+
"link": link,
|
| 262 |
+
"description": _strip_html(getattr(e, "summary", "") or "")[:1500],
|
| 263 |
+
"location": loc,
|
| 264 |
+
"posted_date": getattr(e, "published", "") or "",
|
| 265 |
+
"_source_board": "personio",
|
| 266 |
+
})
|
| 267 |
+
return out
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
_FETCHERS = {
|
| 271 |
+
"greenhouse": fetch_greenhouse,
|
| 272 |
+
"lever": fetch_lever,
|
| 273 |
+
"workday": fetch_workday,
|
| 274 |
+
"smartrecruiters": fetch_smartrecruiters,
|
| 275 |
+
"personio": fetch_personio,
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
def fetch_ats_jobs(url: str) -> list[dict]:
|
| 280 |
+
"""Auto-dispatch to the right ATS fetcher based on URL pattern."""
|
| 281 |
+
ats = detect_ats(url)
|
| 282 |
+
if ats and ats in _FETCHERS:
|
| 283 |
+
return _FETCHERS[ats](url)
|
| 284 |
+
return []
|
| 285 |
+
|
| 286 |
+
|
| 287 |
+
# =============================================================================
|
| 288 |
+
# Run all configured Curium clients
|
| 289 |
+
# =============================================================================
|
| 290 |
+
|
| 291 |
+
def _config() -> dict:
|
| 292 |
+
with open(CONFIG_PATH, "r") as f:
|
| 293 |
+
return yaml.safe_load(f)
|
| 294 |
+
|
| 295 |
+
|
| 296 |
+
def run_all_client_careers(progress_cb: Optional[Callable[[str], None]] = None) -> list[dict]:
|
| 297 |
+
"""Walk every curium_clients entry that has an `ats_url` set, fetch
|
| 298 |
+
that client's senior+relevant roles, return as a flat list of leads
|
| 299 |
+
in the same shape as Adzuna/scraper output (so the existing job
|
| 300 |
+
pipeline can persist them unchanged).
|
| 301 |
+
|
| 302 |
+
Each lead has the client name attached as `company` so it lands in
|
| 303 |
+
the right collator company record.
|
| 304 |
+
"""
|
| 305 |
+
cfg = _config()
|
| 306 |
+
out: list[dict] = []
|
| 307 |
+
clients = cfg.get("curium_clients", []) or []
|
| 308 |
+
n_with_url = 0
|
| 309 |
+
for c in clients:
|
| 310 |
+
client_name = (c.get("name") or "").strip()
|
| 311 |
+
ats_url = (c.get("ats_url") or "").strip()
|
| 312 |
+
if not client_name or not ats_url:
|
| 313 |
+
continue
|
| 314 |
+
n_with_url += 1
|
| 315 |
+
ats = detect_ats(ats_url)
|
| 316 |
+
if progress_cb:
|
| 317 |
+
progress_cb(f"Careers: {client_name} ({ats or 'unknown'})…")
|
| 318 |
+
try:
|
| 319 |
+
jobs = fetch_ats_jobs(ats_url)
|
| 320 |
+
except Exception as e:
|
| 321 |
+
if progress_cb:
|
| 322 |
+
progress_cb(f" {client_name} fetch failed: {type(e).__name__}: {e}")
|
| 323 |
+
continue
|
| 324 |
+
kept = 0
|
| 325 |
+
for j in jobs:
|
| 326 |
+
if not _is_relevant_title(j.get("title", "")):
|
| 327 |
+
continue
|
| 328 |
+
j["company"] = client_name
|
| 329 |
+
out.append(j)
|
| 330 |
+
kept += 1
|
| 331 |
+
if progress_cb:
|
| 332 |
+
progress_cb(f" {client_name}: {kept}/{len(jobs)} relevant senior roles")
|
| 333 |
+
if progress_cb:
|
| 334 |
+
progress_cb(f"Careers total: {len(out)} senior roles across {n_with_url} clients with ats_url set")
|
| 335 |
+
return out
|
|
@@ -477,11 +477,37 @@ Output ONLY the 5 bullets in markdown, no preamble, no headings, no closing rema
|
|
| 477 |
else:
|
| 478 |
self.log(" Adzuna API not configured (set ADZUNA_APP_ID + ADZUNA_APP_KEY for reliable jobs). Falling back to scraping…")
|
| 479 |
|
| 480 |
-
#
|
| 481 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 482 |
# Phase 1b: Playwright scraping fallback. Frequently blocked on
|
| 483 |
# shared cloud IPs (HF Spaces) by Cloudflare bot detection, so we
|
| 484 |
-
# only run it when Adzuna didn't deliver.
|
| 485 |
if len(all_jobs) >= 20:
|
| 486 |
self.log(f" Scrape phase skipped — Adzuna returned {len(all_jobs)} jobs.")
|
| 487 |
else:
|
|
|
|
| 477 |
else:
|
| 478 |
self.log(" Adzuna API not configured (set ADZUNA_APP_ID + ADZUNA_APP_KEY for reliable jobs). Falling back to scraping…")
|
| 479 |
|
| 480 |
+
# ---- Phase 1c: Careers-page scraping for Curium clients --------
|
| 481 |
+
# Hits public ATS APIs (Greenhouse/Lever/Workday/SmartRecruiters/
|
| 482 |
+
# Personio) for any curium_client with `ats_url` set in config.
|
| 483 |
+
# Catches senior strategic hires that companies post to their own
|
| 484 |
+
# careers site first — high-quality complement to Adzuna's broad
|
| 485 |
+
# keyword search.
|
| 486 |
+
try:
|
| 487 |
+
import careers_scraper
|
| 488 |
+
self.log(" Careers-page scraping (Curium client ATS APIs)…")
|
| 489 |
+
client_jobs = careers_scraper.run_all_client_careers(
|
| 490 |
+
progress_cb=lambda m: self.log(f" {m}"),
|
| 491 |
+
)
|
| 492 |
+
for j in client_jobs:
|
| 493 |
+
text = f"{j.get('title','')} {j.get('description','')} {j.get('location','')}".lower()
|
| 494 |
+
us_signals = ['san francisco', 'new york', 'usa only', 'us only',
|
| 495 |
+
'remote us', 'california', 'texas', 'florida',
|
| 496 |
+
'chicago', 'boston', 'seattle']
|
| 497 |
+
# Don't reject for US-located roles if there's also a
|
| 498 |
+
# UK/EMEA indicator — global tenants list everywhere.
|
| 499 |
+
if any(sig in text for sig in us_signals) \
|
| 500 |
+
and "uk" not in text and "united kingdom" not in text \
|
| 501 |
+
and "london" not in text:
|
| 502 |
+
continue
|
| 503 |
+
all_jobs.append(j)
|
| 504 |
+
self.log(f" Careers-scrape kept {len(client_jobs)} client postings (added to Adzuna pool)")
|
| 505 |
+
except Exception as e:
|
| 506 |
+
self.log(f" ⚠️ Careers-scrape failed: {str(e)[:80]}")
|
| 507 |
+
|
| 508 |
# Phase 1b: Playwright scraping fallback. Frequently blocked on
|
| 509 |
# shared cloud IPs (HF Spaces) by Cloudflare bot detection, so we
|
| 510 |
+
# only run it when Adzuna + careers-scrape didn't deliver.
|
| 511 |
if len(all_jobs) >= 20:
|
| 512 |
self.log(f" Scrape phase skipped — Adzuna returned {len(all_jobs)} jobs.")
|
| 513 |
else:
|
|
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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|
+
For each curium_clients entry, derives a URL slug from the client name
|
| 7 |
+
and probes the standard endpoints for each ATS. Reports which (if any)
|
| 8 |
+
returns a valid response with non-empty job postings.
|
| 9 |
+
|
| 10 |
+
Run output is human-readable and print-only — copy the discovered
|
| 11 |
+
ats_url into config.yaml under the client manually. No automatic
|
| 12 |
+
config edits to keep the diff visible.
|
| 13 |
+
|
| 14 |
+
Usage:
|
| 15 |
+
cd /Users/pierslyon/Documents/AI-sales-tool
|
| 16 |
+
venv/bin/python scripts/discover_ats.py
|
| 17 |
+
|
| 18 |
+
# Or restrict to one client:
|
| 19 |
+
venv/bin/python scripts/discover_ats.py --client "Premier Foods"
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
from __future__ import annotations
|
| 23 |
+
|
| 24 |
+
import argparse
|
| 25 |
+
import re
|
| 26 |
+
import sys
|
| 27 |
+
from pathlib import Path
|
| 28 |
+
|
| 29 |
+
REPO_ROOT = Path(__file__).resolve().parent.parent
|
| 30 |
+
sys.path.insert(0, str(REPO_ROOT))
|
| 31 |
+
|
| 32 |
+
import requests
|
| 33 |
+
import yaml
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def slugify_variants(name: str) -> list[str]:
|
| 37 |
+
"""Produce common slug variants companies use for ATS subdomains."""
|
| 38 |
+
n = name.lower().strip()
|
| 39 |
+
n = re.sub(r"[^a-z0-9]+", " ", n)
|
| 40 |
+
parts = n.split()
|
| 41 |
+
out = set()
|
| 42 |
+
if not parts:
|
| 43 |
+
return []
|
| 44 |
+
out.add("".join(parts))
|
| 45 |
+
out.add("-".join(parts))
|
| 46 |
+
out.add(parts[0])
|
| 47 |
+
if len(parts) > 1:
|
| 48 |
+
out.add(parts[0] + parts[1])
|
| 49 |
+
out.add(parts[0] + "-" + parts[1])
|
| 50 |
+
# Drop common "noise" words
|
| 51 |
+
skip = {"group", "ltd", "limited", "plc", "uk", "the", "and"}
|
| 52 |
+
filtered = [p for p in parts if p not in skip]
|
| 53 |
+
if filtered:
|
| 54 |
+
out.add("".join(filtered))
|
| 55 |
+
out.add("-".join(filtered))
|
| 56 |
+
out.add(filtered[0])
|
| 57 |
+
return sorted(out)
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def probe_url(url: str, timeout: int = 8) -> tuple[bool, str]:
|
| 61 |
+
"""Returns (ok, summary). ok=True if URL returns plausible job data."""
|
| 62 |
+
try:
|
| 63 |
+
r = requests.get(url, timeout=timeout)
|
| 64 |
+
except requests.RequestException as e:
|
| 65 |
+
return False, f"err {type(e).__name__}"
|
| 66 |
+
if r.status_code != 200:
|
| 67 |
+
return False, f"HTTP {r.status_code}"
|
| 68 |
+
# Greenhouse / Lever / SmartRecruiters return JSON with postings
|
| 69 |
+
if "json" in (r.headers.get("Content-Type", "") or "").lower() or r.text.startswith(("[", "{")):
|
| 70 |
+
try:
|
| 71 |
+
data = r.json()
|
| 72 |
+
except Exception:
|
| 73 |
+
return False, "non-JSON body"
|
| 74 |
+
if isinstance(data, dict):
|
| 75 |
+
if "jobs" in data and data["jobs"]:
|
| 76 |
+
return True, f"Greenhouse — {len(data['jobs'])} jobs"
|
| 77 |
+
if "content" in data and data["content"]:
|
| 78 |
+
return True, f"SmartRecruiters — {len(data['content'])} postings"
|
| 79 |
+
if isinstance(data, list) and data:
|
| 80 |
+
return True, f"Lever — {len(data)} postings"
|
| 81 |
+
return False, "JSON empty"
|
| 82 |
+
# Workday endpoint requires POST; try that
|
| 83 |
+
return False, "non-JSON GET (try POST?)"
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
def probe_workday(slug: str, sites: list[str] = None,
|
| 87 |
+
timeout: int = 8) -> tuple[bool, str]:
|
| 88 |
+
sites = sites or ["External", "External_Career_Site", "Careers", "external", "Career"]
|
| 89 |
+
for host_var in (".wd1", ".wd3", ".wd5", ".wd103", ".wd2"):
|
| 90 |
+
for site in sites:
|
| 91 |
+
url = (f"https://{slug}{host_var}.myworkdayjobs.com/wday/cxs/"
|
| 92 |
+
f"{slug}/{site}/jobs")
|
| 93 |
+
try:
|
| 94 |
+
r = requests.post(
|
| 95 |
+
url,
|
| 96 |
+
headers={"Content-Type": "application/json",
|
| 97 |
+
"Accept": "application/json"},
|
| 98 |
+
json={"limit": 5, "offset": 0, "searchText": ""},
|
| 99 |
+
timeout=timeout,
|
| 100 |
+
)
|
| 101 |
+
except requests.RequestException:
|
| 102 |
+
continue
|
| 103 |
+
if r.status_code == 200:
|
| 104 |
+
try:
|
| 105 |
+
data = r.json()
|
| 106 |
+
except Exception:
|
| 107 |
+
continue
|
| 108 |
+
count = len(data.get("jobPostings", []) or [])
|
| 109 |
+
if count:
|
| 110 |
+
return True, f"Workday {host_var}/{site} — {count} postings", url
|
| 111 |
+
return False, "no Workday endpoint found", ""
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
def probe_personio(slug: str, timeout: int = 8) -> tuple[bool, str, str]:
|
| 115 |
+
for tld in ("com", "de"):
|
| 116 |
+
url = f"https://{slug}.jobs.personio.{tld}/xml"
|
| 117 |
+
try:
|
| 118 |
+
r = requests.get(url, timeout=timeout)
|
| 119 |
+
except requests.RequestException:
|
| 120 |
+
continue
|
| 121 |
+
if r.status_code == 200 and "<job" in r.text.lower():
|
| 122 |
+
n = r.text.lower().count("<job")
|
| 123 |
+
return True, f"Personio .{tld} — ~{n} <job> nodes", url
|
| 124 |
+
return False, "no Personio endpoint", ""
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
def discover_for_client(name: str) -> list[tuple[str, str, str]]:
|
| 128 |
+
"""Returns [(ats, summary, url), ...] for each working endpoint found."""
|
| 129 |
+
results: list[tuple[str, str, str]] = []
|
| 130 |
+
slugs = slugify_variants(name)
|
| 131 |
+
|
| 132 |
+
print(f"\n--- {name} (slugs: {', '.join(slugs)}) ---")
|
| 133 |
+
|
| 134 |
+
# Greenhouse
|
| 135 |
+
for slug in slugs:
|
| 136 |
+
url = f"https://boards-api.greenhouse.io/v1/boards/{slug}/jobs"
|
| 137 |
+
ok, msg = probe_url(url)
|
| 138 |
+
if ok:
|
| 139 |
+
results.append(("greenhouse", msg, url))
|
| 140 |
+
print(f" ✓ Greenhouse [{slug}]: {msg}")
|
| 141 |
+
print(f" {url}")
|
| 142 |
+
break
|
| 143 |
+
|
| 144 |
+
# Lever
|
| 145 |
+
for slug in slugs:
|
| 146 |
+
url = f"https://api.lever.co/v0/postings/{slug}?mode=json"
|
| 147 |
+
ok, msg = probe_url(url)
|
| 148 |
+
if ok:
|
| 149 |
+
results.append(("lever", msg, url))
|
| 150 |
+
print(f" ✓ Lever [{slug}]: {msg}")
|
| 151 |
+
print(f" {url}")
|
| 152 |
+
break
|
| 153 |
+
|
| 154 |
+
# SmartRecruiters
|
| 155 |
+
for slug in slugs:
|
| 156 |
+
url = f"https://api.smartrecruiters.com/v1/companies/{slug}/postings"
|
| 157 |
+
ok, msg = probe_url(url)
|
| 158 |
+
if ok:
|
| 159 |
+
results.append(("smartrecruiters", msg, url))
|
| 160 |
+
print(f" ✓ SmartRecruiters [{slug}]: {msg}")
|
| 161 |
+
print(f" {url}")
|
| 162 |
+
break
|
| 163 |
+
|
| 164 |
+
# Workday — POST-based, try a few hostname variations
|
| 165 |
+
for slug in slugs:
|
| 166 |
+
ok, msg, found_url = probe_workday(slug)
|
| 167 |
+
if ok:
|
| 168 |
+
results.append(("workday", msg, found_url))
|
| 169 |
+
print(f" ✓ Workday [{slug}]: {msg}")
|
| 170 |
+
print(f" {found_url}")
|
| 171 |
+
break
|
| 172 |
+
|
| 173 |
+
# Personio
|
| 174 |
+
for slug in slugs:
|
| 175 |
+
ok, msg, found_url = probe_personio(slug)
|
| 176 |
+
if ok:
|
| 177 |
+
results.append(("personio", msg, found_url))
|
| 178 |
+
print(f" ✓ Personio [{slug}]: {msg}")
|
| 179 |
+
print(f" {found_url}")
|
| 180 |
+
break
|
| 181 |
+
|
| 182 |
+
if not results:
|
| 183 |
+
print(f" ✗ No public ATS endpoint discovered. Probably uses a bespoke careers site.")
|
| 184 |
+
return results
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def main() -> int:
|
| 188 |
+
parser = argparse.ArgumentParser()
|
| 189 |
+
parser.add_argument("--client",
|
| 190 |
+
help="Restrict to a specific client name (case-insensitive substring match)")
|
| 191 |
+
args = parser.parse_args()
|
| 192 |
+
|
| 193 |
+
config_path = REPO_ROOT / "config.yaml"
|
| 194 |
+
with open(config_path, "r") as f:
|
| 195 |
+
cfg = yaml.safe_load(f)
|
| 196 |
+
clients = cfg.get("curium_clients", []) or []
|
| 197 |
+
if args.client:
|
| 198 |
+
needle = args.client.lower()
|
| 199 |
+
clients = [c for c in clients if needle in (c.get("name") or "").lower()]
|
| 200 |
+
|
| 201 |
+
print(f"Probing {len(clients)} clients across 5 ATS platforms…")
|
| 202 |
+
all_results: dict[str, list] = {}
|
| 203 |
+
for c in clients:
|
| 204 |
+
name = c.get("name", "")
|
| 205 |
+
if not name:
|
| 206 |
+
continue
|
| 207 |
+
results = discover_for_client(name)
|
| 208 |
+
if results:
|
| 209 |
+
all_results[name] = results
|
| 210 |
+
|
| 211 |
+
print()
|
| 212 |
+
print("=" * 64)
|
| 213 |
+
print(f"Summary: {len(all_results)}/{len(clients)} clients have a discoverable ATS")
|
| 214 |
+
print("=" * 64)
|
| 215 |
+
if all_results:
|
| 216 |
+
print()
|
| 217 |
+
print("Add the ats_url for each discovered client to config.yaml:")
|
| 218 |
+
print()
|
| 219 |
+
for name, results in all_results.items():
|
| 220 |
+
best_url = results[0][2]
|
| 221 |
+
print(f" - name: \"{name}\"")
|
| 222 |
+
print(f" ats_url: \"{best_url}\"")
|
| 223 |
+
print()
|
| 224 |
+
print("Then run a workflow_dispatch to verify they pull on the next hunt.")
|
| 225 |
+
else:
|
| 226 |
+
print("\nNo clients discovered. They likely use bespoke careers pages — would")
|
| 227 |
+
print("need per-client HTML scrapers, not worth the maintenance burden.")
|
| 228 |
+
return 0
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
if __name__ == "__main__":
|
| 232 |
+
sys.exit(main())
|