Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
# Adzuna API credentials
|
| 5 |
+
APP_ID = '7f181750' # Replace with your actual app_id
|
| 6 |
+
APP_KEY = 'f9ff26183103df54b600fe7de7d75ee2' # Replace with your actual app_key
|
| 7 |
+
COUNTRY = 'gb' # Country code (e.g., 'gb' for United Kingdom)
|
| 8 |
+
|
| 9 |
+
# Streamlit app title
|
| 10 |
+
st.title('Job Search Application')
|
| 11 |
+
|
| 12 |
+
# Input field for job keyword
|
| 13 |
+
keyword = st.text_input('Enter job keyword:', '')
|
| 14 |
+
|
| 15 |
+
# Function to fetch job listings from Adzuna API
|
| 16 |
+
def fetch_jobs(keyword):
|
| 17 |
+
url = f'https://api.adzuna.com/v1/api/jobs/{COUNTRY}/search/1'
|
| 18 |
+
params = {
|
| 19 |
+
'app_id': APP_ID,
|
| 20 |
+
'app_key': APP_KEY,
|
| 21 |
+
'results_per_page': 10,
|
| 22 |
+
'what': keyword,
|
| 23 |
+
'content-type': 'application/json'
|
| 24 |
+
}
|
| 25 |
+
response = requests.get(url, params=params)
|
| 26 |
+
if response.status_code == 200:
|
| 27 |
+
return response.json().get('results', [])
|
| 28 |
+
else:
|
| 29 |
+
st.error('Error fetching data from Adzuna API')
|
| 30 |
+
return []
|
| 31 |
+
|
| 32 |
+
# Display job listings when a keyword is entered
|
| 33 |
+
if keyword:
|
| 34 |
+
st.subheader(f'Results for "{keyword}":')
|
| 35 |
+
jobs = fetch_jobs(keyword)
|
| 36 |
+
if jobs:
|
| 37 |
+
for job in jobs:
|
| 38 |
+
st.markdown(f"**{job['title']}**")
|
| 39 |
+
st.markdown(f"*Company:* {job.get('company', {}).get('display_name', 'N/A')}")
|
| 40 |
+
st.markdown(f"*Location:* {job.get('location', {}).get('display_name', 'N/A')}")
|
| 41 |
+
st.markdown(f"*Salary:* {job.get('salary_min', 'N/A')} - {job.get('salary_max', 'N/A')}")
|
| 42 |
+
st.markdown(f"*Description:* {job.get('description', 'N/A')[:200]}...")
|
| 43 |
+
st.markdown(f"[More Info]({job['redirect_url']})")
|
| 44 |
+
st.markdown('---')
|
| 45 |
+
else:
|
| 46 |
+
st.write('No job listings found.')
|