File size: 2,869 Bytes
4a89a1a
655748a
 
4a89a1a
3236cbf
655748a
 
 
4a89a1a
655748a
 
 
 
 
 
4a89a1a
655748a
 
 
 
 
a29607c
4a89a1a
 
 
655748a
4a89a1a
 
9a31d86
4a89a1a
 
a29607c
4a89a1a
 
a29607c
4a89a1a
 
 
 
 
a29607c
4a89a1a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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.")