Spaces:
Running
Running
Upload 2 files
Browse files- app.py +66 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import requests
|
3 |
+
|
4 |
+
# API credentials
|
5 |
+
API_KEY = "ef4899abb4msh72ad9a5b860e697p191aa4jsn14fbc3ce6661"
|
6 |
+
API_HOST = "jsearch.p.rapidapi.com"
|
7 |
+
|
8 |
+
# Function to fetch job openings
|
9 |
+
def get_job_openings(job_title, location, location_type, experience):
|
10 |
+
url = "https://jsearch.p.rapidapi.com/search"
|
11 |
+
querystring = {
|
12 |
+
"query": f"{job_title} in {location}",
|
13 |
+
"page": "1",
|
14 |
+
"num_pages": "1",
|
15 |
+
"remote_jobs_only": "true" if location_type == "REMOTE" else "false",
|
16 |
+
"employment_types": experience
|
17 |
+
}
|
18 |
+
headers = {
|
19 |
+
"x-rapidapi-key": API_KEY,
|
20 |
+
"x-rapidapi-host": API_HOST
|
21 |
+
}
|
22 |
+
|
23 |
+
response = requests.get(url, headers=headers, params=querystring)
|
24 |
+
if response.status_code == 200:
|
25 |
+
return response.json()
|
26 |
+
else:
|
27 |
+
st.error(f"Error {response.status_code}: {response.text}")
|
28 |
+
return None
|
29 |
+
|
30 |
+
# Streamlit UI
|
31 |
+
st.set_page_config(page_title="Job Search", page_icon="π§βπΌ", layout="centered")
|
32 |
+
|
33 |
+
st.title("π§βπΌ Job Search Chatbot")
|
34 |
+
st.write("Find the latest job openings based on your preferences.")
|
35 |
+
|
36 |
+
# User inputs
|
37 |
+
job_title = st.text_input("Enter Job Title:", placeholder="e.g., Node.js Developer")
|
38 |
+
location = st.text_input("Enter Location:", placeholder="e.g., New York")
|
39 |
+
location_type = st.selectbox("Location Type:", ["ANY", "ON_SITE", "REMOTE", "HYBRID"])
|
40 |
+
experience = st.selectbox("Experience Level:", ["FULLTIME", "PARTTIME", "INTERN", "CONTRACTOR"])
|
41 |
+
|
42 |
+
# Button to fetch job openings
|
43 |
+
if st.button("Search Jobs"):
|
44 |
+
if job_title and location:
|
45 |
+
with st.spinner("Fetching job openings..."):
|
46 |
+
data = get_job_openings(job_title, location, location_type, experience)
|
47 |
+
if data and 'data' in data:
|
48 |
+
st.success("Job Openings Retrieved!")
|
49 |
+
jobs = data['data']
|
50 |
+
|
51 |
+
if jobs:
|
52 |
+
for idx, job in enumerate(jobs, start=1):
|
53 |
+
st.subheader(f"{idx}. {job.get('job_title', 'No Title')}")
|
54 |
+
st.write(f"*Company:* {job.get('employer_name', 'Unknown')}")
|
55 |
+
st.write(f"*Location:* {job.get('job_city', 'Unknown')}, {job.get('job_country', '')}")
|
56 |
+
st.write(f"*Type:* {job.get('job_employment_type', 'N/A')}")
|
57 |
+
st.write(f"*Posted On:* {job.get('job_posted_at_datetime_utc', 'N/A')}")
|
58 |
+
st.write(f"*Deadline:* {job.get('job_offer_expiration_datetime_utc', 'N/A')}")
|
59 |
+
st.write(f"[π View Job Posting]({job.get('job_apply_link', '#')})")
|
60 |
+
st.write("---")
|
61 |
+
else:
|
62 |
+
st.warning("No job openings found. Please try different inputs.")
|
63 |
+
else:
|
64 |
+
st.warning("No job data found. Please try again.")
|
65 |
+
else:
|
66 |
+
st.error("Please enter both job title and location.")
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
requests
|
2 |
+
streamlit
|