Spaces:
Sleeping
Sleeping
File size: 938 Bytes
0b90517 2fd4cba 0b90517 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import requests
def fetch_jobs(parsed):
api_url = "https://api.adzuna.com/v1/api/jobs/us/search/1"
params = {
"app_id": "f4efd3a2",
"app_key": "5702f3c0507ac69f98aa15f855b06901",
"results_per_page": 5,
"what": ", ".join(parsed["skills"][:5]),
"where": "remote",
"content-type": "application/json"
}
try:
res = requests.get(api_url, params=params)
data = res.json()
return [
{
"title": x["title"],
"company": x["company"]["display_name"],
"location": x["location"]["display_name"],
"salary": x.get("salary_is_predicted", "N/A"),
"url": x["redirect_url"]
}
for x in data.get("results", [])
]
except Exception as e:
return [{"title": "No job listings found.", "company": "", "location": "", "salary": "", "url": ""}] |