engrharis commited on
Commit
bf8127e
·
verified ·
1 Parent(s): db15c82

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -36
app.py CHANGED
@@ -1,42 +1,41 @@
1
  import streamlit as st
2
 
3
- # Initialize platform URLs (you can adjust these as needed)
 
 
 
 
 
 
 
 
4
  platforms = {
5
  "LinkedIn": "https://www.linkedin.com/jobs/search/?keywords={job}&location={city}",
6
- "Indeed": "https://www.indeed.com/jobs?q={job}&l={city}",
7
- "Glassdoor": "https://www.glassdoor.com/Job/jobs.htm?sc.keyword={job}&locT=&locId=&jobType=&fromAge=any&radius=100&city={city}"
8
  }
9
 
10
- # Initialize inputs
11
- selected_city = st.text_input("Enter City")
12
- job_keyword = st.text_input("Enter Job Keyword")
13
- selected_platform = st.selectbox("Select Job Platform", options=["", "LinkedIn", "Indeed", "Glassdoor"])
14
-
15
- # Initialize button state in session
16
- if 'button_state' not in st.session_state:
17
- st.session_state['button_state'] = "Search Jobs"
18
-
19
- # Check if all inputs are selected
20
- if selected_city == "" or job_keyword.strip() == "" or selected_platform == "":
21
- st.warning("Please select a city, enter a job keyword, and choose a platform.")
22
- else:
23
- if st.button(st.session_state['button_state']):
24
- if st.session_state['button_state'] == "Search Jobs":
25
- # Construct the URL
26
- base_url = platforms[selected_platform]
27
- search_url = base_url.format(job=job_keyword.replace(" ", "+"), city=selected_city)
28
-
29
- # Change button state
30
- st.session_state['button_state'] = "See Jobs"
31
-
32
- # Show search URL for debugging purposes (optional)
33
- st.write(f"Search URL: {search_url}")
34
-
35
- elif st.session_state['button_state'] == "See Jobs":
36
- # Open the link in a new tab
37
- base_url = platforms[selected_platform]
38
- search_url = base_url.format(job=job_keyword.replace(" ", "+"), city=selected_city)
39
- st.markdown(f'<a href="{search_url}" target="_blank">Open Jobs in New Tab</a>', unsafe_allow_html=True)
40
-
41
- # Reset button state for new searches
42
- st.session_state['button_state'] = "Search Jobs"
 
1
  import streamlit as st
2
 
3
+ # Expanded list of Pakistani cities
4
+ cities = [
5
+ "Karachi", "Lahore", "Islamabad", "Rawalpindi", "Peshawar", "Quetta",
6
+ "Faisalabad", "Multan", "Sialkot", "Hyderabad", "Gujranwala", "Bahawalpur",
7
+ "Abbottabad", "Sargodha", "Mardan", "Mirpur", "Sukkur", "Larkana",
8
+ "Chiniot", "Sheikhupura", "Gujrat", "Jhelum", "Dera Ghazi Khan", "Nawabshah"
9
+ ]
10
+
11
+ # Platforms with job search URLs
12
  platforms = {
13
  "LinkedIn": "https://www.linkedin.com/jobs/search/?keywords={job}&location={city}",
14
+ "Indeed": "https://pk.indeed.com/jobs?q={job}&l={city}",
15
+ "National Job Portal": "https://njp.gov.pk/job_search?keywords={job}&city={city}"
16
  }
17
 
18
+ # App Title
19
+ st.title("Job Search Portal")
20
+
21
+ # User Inputs
22
+ st.subheader("Search for Jobs in Pakistan")
23
+ selected_city = st.selectbox("Select your city:", cities)
24
+ job_keyword = st.text_input("Enter job title or keywords:")
25
+ selected_platform = st.selectbox("Choose the job platform:", list(platforms.keys()))
26
+
27
+ # Show the Search button and create the link if clicked
28
+ if st.button("Search Jobs"):
29
+ if not job_keyword.strip():
30
+ st.warning("Please enter a job title or keyword.")
31
+ else:
32
+ # Construct the URL for the selected platform
33
+ base_url = platforms[selected_platform]
34
+ search_url = base_url.format(job=job_keyword.replace(" ", "+"), city=selected_city)
35
+
36
+ # Create the dynamic link for the platform
37
+ link_text = f"See {selected_platform} Jobs in {selected_city}"
38
+
39
+ # Display the dynamic link
40
+ st.markdown(f"[{link_text}]({search_url})", unsafe_allow_html=True)
41
+ st.success(f"Click the link above to see jobs on {selected_platform}.")