import streamlit as st import requests # Function to fetch jobs from the Adzuna API def fetch_jobs(app_id, app_key, keywords, location="Calgary", results_per_page=10): base_url = "http://api.adzuna.com/v1/api/jobs/ca/search/1" # API endpoint for Canada params = { "app_id": app_id, "app_key": app_key, "results_per_page": results_per_page, "what": keywords, "where": location, "content-type": "application/json" } response = requests.get(base_url, params=params) if response.status_code == 200: return response.json().get('results', []) else: st.error("Failed to fetch jobs. Status code: " + str(response.status_code)) return [] # Streamlit app def main(): st.title("Job Search App") st.write("Enter keywords to find relevant jobs.") # Input fields for the job search keywords = st.text_input("Enter job keywords (e.g., AI, Data Science, Software Engineer):", "") location = st.text_input("Enter location (default is Calgary):", "Calgary") # API credentials (replace with your own app_id and app_key) app_id = "7f181750" app_key = "f9ff26183103df54b600fe7de7d75ee2" if st.button("Search Jobs"): if keywords: jobs = fetch_jobs(app_id, app_key, keywords, location) if jobs: st.success(f"Found {len(jobs)} jobs for '{keywords}' in {location}. Showing top 10 results.") for job in jobs[:10]: st.subheader(job['title']) st.write("Location:", ', '.join(job['location']['area'])) st.write("Description:", job['description']) st.write("Salary Range:", f"{job.get('salary_min', 'N/A')} - {job.get('salary_max', 'N/A')}") st.write("[Job Link](" + job['redirect_url'] + ")") st.write("Posted Date:", job.get('created', 'N/A')) st.write("---") else: st.warning(f"No jobs found for '{keywords}' in {location}.") else: st.warning("Please enter job keywords to search.") if __name__ == "__main__": main()