Spaces:
Sleeping
Sleeping
Piers Lyon
Claude Opus 4.7 (1M context)
Careers-page scraping infrastructure (Greenhouse/Lever/Workday/SR/Personio)
b48405d Download scripts/discover_ats.py from mipwr-admin/curium-intel: direct link, hf CLI and curl.
- Browser
- Download file 8.14 kB
-
https://huggingface.co/spaces/mipwr-admin/curium-intel/resolve/main/scripts/discover_ats.py
- Command line
-
hf download hf://spaces/mipwr-admin/curium-intel/scripts/discover_ats.py
-
curl -L -o discover_ats.py https://huggingface.co/spaces/mipwr-admin/curium-intel/resolve/main/scripts/discover_ats.py
8.14 kB
| #!/usr/bin/env python3 | |
| """ | |
| Auto-discover the ATS (Greenhouse / Lever / Workday / SmartRecruiters / | |
| Personio) used by each Curium client. | |
| For each curium_clients entry, derives a URL slug from the client name | |
| and probes the standard endpoints for each ATS. Reports which (if any) | |
| returns a valid response with non-empty job postings. | |
| Run output is human-readable and print-only — copy the discovered | |
| ats_url into config.yaml under the client manually. No automatic | |
| config edits to keep the diff visible. | |
| Usage: | |
| cd /Users/pierslyon/Documents/AI-sales-tool | |
| venv/bin/python scripts/discover_ats.py | |
| # Or restrict to one client: | |
| venv/bin/python scripts/discover_ats.py --client "Premier Foods" | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import re | |
| import sys | |
| from pathlib import Path | |
| REPO_ROOT = Path(__file__).resolve().parent.parent | |
| sys.path.insert(0, str(REPO_ROOT)) | |
| import requests | |
| import yaml | |
| def slugify_variants(name: str) -> list[str]: | |
| """Produce common slug variants companies use for ATS subdomains.""" | |
| n = name.lower().strip() | |
| n = re.sub(r"[^a-z0-9]+", " ", n) | |
| parts = n.split() | |
| out = set() | |
| if not parts: | |
| return [] | |
| out.add("".join(parts)) | |
| out.add("-".join(parts)) | |
| out.add(parts[0]) | |
| if len(parts) > 1: | |
| out.add(parts[0] + parts[1]) | |
| out.add(parts[0] + "-" + parts[1]) | |
| # Drop common "noise" words | |
| skip = {"group", "ltd", "limited", "plc", "uk", "the", "and"} | |
| filtered = [p for p in parts if p not in skip] | |
| if filtered: | |
| out.add("".join(filtered)) | |
| out.add("-".join(filtered)) | |
| out.add(filtered[0]) | |
| return sorted(out) | |
| def probe_url(url: str, timeout: int = 8) -> tuple[bool, str]: | |
| """Returns (ok, summary). ok=True if URL returns plausible job data.""" | |
| try: | |
| r = requests.get(url, timeout=timeout) | |
| except requests.RequestException as e: | |
| return False, f"err {type(e).__name__}" | |
| if r.status_code != 200: | |
| return False, f"HTTP {r.status_code}" | |
| # Greenhouse / Lever / SmartRecruiters return JSON with postings | |
| if "json" in (r.headers.get("Content-Type", "") or "").lower() or r.text.startswith(("[", "{")): | |
| try: | |
| data = r.json() | |
| except Exception: | |
| return False, "non-JSON body" | |
| if isinstance(data, dict): | |
| if "jobs" in data and data["jobs"]: | |
| return True, f"Greenhouse — {len(data['jobs'])} jobs" | |
| if "content" in data and data["content"]: | |
| return True, f"SmartRecruiters — {len(data['content'])} postings" | |
| if isinstance(data, list) and data: | |
| return True, f"Lever — {len(data)} postings" | |
| return False, "JSON empty" | |
| # Workday endpoint requires POST; try that | |
| return False, "non-JSON GET (try POST?)" | |
| def probe_workday(slug: str, sites: list[str] = None, | |
| timeout: int = 8) -> tuple[bool, str]: | |
| sites = sites or ["External", "External_Career_Site", "Careers", "external", "Career"] | |
| for host_var in (".wd1", ".wd3", ".wd5", ".wd103", ".wd2"): | |
| for site in sites: | |
| url = (f"https://{slug}{host_var}.myworkdayjobs.com/wday/cxs/" | |
| f"{slug}/{site}/jobs") | |
| try: | |
| r = requests.post( | |
| url, | |
| headers={"Content-Type": "application/json", | |
| "Accept": "application/json"}, | |
| json={"limit": 5, "offset": 0, "searchText": ""}, | |
| timeout=timeout, | |
| ) | |
| except requests.RequestException: | |
| continue | |
| if r.status_code == 200: | |
| try: | |
| data = r.json() | |
| except Exception: | |
| continue | |
| count = len(data.get("jobPostings", []) or []) | |
| if count: | |
| return True, f"Workday {host_var}/{site} — {count} postings", url | |
| return False, "no Workday endpoint found", "" | |
| def probe_personio(slug: str, timeout: int = 8) -> tuple[bool, str, str]: | |
| for tld in ("com", "de"): | |
| url = f"https://{slug}.jobs.personio.{tld}/xml" | |
| try: | |
| r = requests.get(url, timeout=timeout) | |
| except requests.RequestException: | |
| continue | |
| if r.status_code == 200 and "<job" in r.text.lower(): | |
| n = r.text.lower().count("<job") | |
| return True, f"Personio .{tld} — ~{n} <job> nodes", url | |
| return False, "no Personio endpoint", "" | |
| def discover_for_client(name: str) -> list[tuple[str, str, str]]: | |
| """Returns [(ats, summary, url), ...] for each working endpoint found.""" | |
| results: list[tuple[str, str, str]] = [] | |
| slugs = slugify_variants(name) | |
| print(f"\n--- {name} (slugs: {', '.join(slugs)}) ---") | |
| # Greenhouse | |
| for slug in slugs: | |
| url = f"https://boards-api.greenhouse.io/v1/boards/{slug}/jobs" | |
| ok, msg = probe_url(url) | |
| if ok: | |
| results.append(("greenhouse", msg, url)) | |
| print(f" ✓ Greenhouse [{slug}]: {msg}") | |
| print(f" {url}") | |
| break | |
| # Lever | |
| for slug in slugs: | |
| url = f"https://api.lever.co/v0/postings/{slug}?mode=json" | |
| ok, msg = probe_url(url) | |
| if ok: | |
| results.append(("lever", msg, url)) | |
| print(f" ✓ Lever [{slug}]: {msg}") | |
| print(f" {url}") | |
| break | |
| # SmartRecruiters | |
| for slug in slugs: | |
| url = f"https://api.smartrecruiters.com/v1/companies/{slug}/postings" | |
| ok, msg = probe_url(url) | |
| if ok: | |
| results.append(("smartrecruiters", msg, url)) | |
| print(f" ✓ SmartRecruiters [{slug}]: {msg}") | |
| print(f" {url}") | |
| break | |
| # Workday — POST-based, try a few hostname variations | |
| for slug in slugs: | |
| ok, msg, found_url = probe_workday(slug) | |
| if ok: | |
| results.append(("workday", msg, found_url)) | |
| print(f" ✓ Workday [{slug}]: {msg}") | |
| print(f" {found_url}") | |
| break | |
| # Personio | |
| for slug in slugs: | |
| ok, msg, found_url = probe_personio(slug) | |
| if ok: | |
| results.append(("personio", msg, found_url)) | |
| print(f" ✓ Personio [{slug}]: {msg}") | |
| print(f" {found_url}") | |
| break | |
| if not results: | |
| print(f" ✗ No public ATS endpoint discovered. Probably uses a bespoke careers site.") | |
| return results | |
| def main() -> int: | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--client", | |
| help="Restrict to a specific client name (case-insensitive substring match)") | |
| args = parser.parse_args() | |
| config_path = REPO_ROOT / "config.yaml" | |
| with open(config_path, "r") as f: | |
| cfg = yaml.safe_load(f) | |
| clients = cfg.get("curium_clients", []) or [] | |
| if args.client: | |
| needle = args.client.lower() | |
| clients = [c for c in clients if needle in (c.get("name") or "").lower()] | |
| print(f"Probing {len(clients)} clients across 5 ATS platforms…") | |
| all_results: dict[str, list] = {} | |
| for c in clients: | |
| name = c.get("name", "") | |
| if not name: | |
| continue | |
| results = discover_for_client(name) | |
| if results: | |
| all_results[name] = results | |
| print() | |
| print("=" * 64) | |
| print(f"Summary: {len(all_results)}/{len(clients)} clients have a discoverable ATS") | |
| print("=" * 64) | |
| if all_results: | |
| print() | |
| print("Add the ats_url for each discovered client to config.yaml:") | |
| print() | |
| for name, results in all_results.items(): | |
| best_url = results[0][2] | |
| print(f" - name: \"{name}\"") | |
| print(f" ats_url: \"{best_url}\"") | |
| print() | |
| print("Then run a workflow_dispatch to verify they pull on the next hunt.") | |
| else: | |
| print("\nNo clients discovered. They likely use bespoke careers pages — would") | |
| print("need per-client HTML scrapers, not worth the maintenance burden.") | |
| return 0 | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |