File size: 915 Bytes
a5203b8
 
f7dfb4d
 
a5203b8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
import requests

ADZUNA_APP_ID = "f4efd3a2"
ADZUNA_APP_KEY = "5702f3c0507ac69f98aa15f855b06901"

def get_jobs(keyword="engineer", location="USA", max_results=5):
    url = f"https://api.adzuna.com/v1/api/jobs/us/search/1"
    params = {
        "app_id": ADZUNA_APP_ID,
        "app_key": ADZUNA_APP_KEY,
        "what": keyword,
        "where": location,
        "results_per_page": max_results,
        "content-type": "application/json",
    }
    response = requests.get(url, params=params)
    if response.status_code == 200:
        data = response.json()
        jobs = []
        for job in data.get("results", []):
            jobs.append({
                "title": job["title"],
                "location": job["location"]["display_name"],
                "url": job["redirect_url"]
            })
        return jobs
    else:
        return [{"title": "Error fetching jobs", "location": "", "url": ""}]