ASNVS's picture
the real update
4a89a1a verified
import streamlit as st
import requests
# API credentials
API_KEY = "c1b9b6be0amsh11316ef9a922bdbp1789f5jsn18a0023eef11"
API_HOST = "jsearch.p.rapidapi.com"
# Function to fetch job openings
def get_job_openings(job_title, location, location_type, experience):
url = "https://jsearch.p.rapidapi.com/search"
querystring = {
"query": f"{job_title} in {location}",
"page": "1",
"num_pages": "1",
"remote_jobs_only": "true" if location_type == "REMOTE" else "false",
"employment_types": experience
}
headers = {
"x-rapidapi-key": API_KEY,
"x-rapidapi-host": API_HOST
}
response = requests.get(url, headers=headers, params=querystring)
if response.status_code == 200:
return response.json()
else:
st.error(f"Error {response.status_code}: {response.text}")
return None
# Streamlit UI
st.set_page_config(page_title="Job Search", page_icon="πŸ§‘β€πŸ’Ό", layout="centered")
st.title("🎯 Career Connect ")
st.write("Find the latest job openings based on your preferences.")
# User inputs
job_title = st.text_input("Enter Job Title:", placeholder="e.g., Node.js Developer")
location = st.text_input("Enter Location:", placeholder="e.g., New York")
location_type = st.selectbox("Location Type:", ["ANY", "ON_SITE", "REMOTE", "HYBRID"])
experience = st.selectbox("Experience Level:", ["FULLTIME", "PARTTIME", "INTERN", "CONTRACTOR"])
# Button to fetch job openings
if st.button("Search Jobs"):
if job_title and location:
with st.spinner("Fetching job openings..."):
data = get_job_openings(job_title, location, location_type, experience)
if data and 'data' in data:
st.success("Job Openings Retrieved!")
jobs = data['data']
if jobs:
for idx, job in enumerate(jobs, start=1):
st.subheader(f"{idx}. {job.get('job_title', 'No Title')}")
st.write(f"*Company:* {job.get('employer_name', 'Unknown')}")
st.write(f"*Location:* {job.get('job_city', 'Unknown')}, {job.get('job_country', '')}")
st.write(f"*Type:* {job.get('job_employment_type', 'N/A')}")
st.write(f"*Posted On:* {job.get('job_posted_at_datetime_utc', 'N/A')}")
st.write(f"*Deadline:* {job.get('job_offer_expiration_datetime_utc', 'N/A')}")
st.write(f"[πŸ”— View Job Posting]({job.get('job_apply_link', '#')})")
st.write("---")
else:
st.warning("No job openings found. Please try different inputs.")
else:
st.warning("No job data found. Please try again.")
else:
st.error("Please enter both job title and location.")