| 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": ""}] |