salary-benchmark/app/services/serper_client.py
DJP da3f5faa91 Initial commit: Salary Benchmark Tool
FastAPI + React + PostgreSQL salary benchmarking tool with AI research pipeline.
- Seed data for 25+ New York roles (junior/mid/senior levels)
- Single + bulk lookup with location alias mapping (NYC -> New York, etc.)
- Research pipeline: Serper -> Firecrawl -> Cohere Rerank -> Claude analysis
- Editable validation UI for AI-proposed benchmarks
- CSV export, Montserrat font, black/white/#FFC407 design
- Fully Dockerized (app + db + frontend)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-02 22:47:32 -04:00

37 lines
1.1 KiB
Python

import httpx
from app.config import settings
async def search_salaries(title: str, location: str) -> dict:
queries = [
f'"{title}" salary range {location} 2025 2026',
f'"{title}" compensation {location} glassdoor levels.fyi',
]
all_results = []
seen_urls = set()
async with httpx.AsyncClient(timeout=30) as client:
for query in queries:
resp = await client.post(
"https://google.serper.dev/search",
headers={"X-API-KEY": settings.serper_api_key},
json={"q": query, "num": 10},
)
resp.raise_for_status()
data = resp.json()
for item in data.get("organic", []):
url = item.get("link", "")
if url not in seen_urls:
seen_urls.add(url)
all_results.append(
{
"title": item.get("title", ""),
"link": url,
"snippet": item.get("snippet", ""),
}
)
return {"results": all_results[:15]}