ArchiMathur commited on
Commit
02cdcc8
·
verified ·
1 Parent(s): 60c42f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -15
app.py CHANGED
@@ -95,11 +95,13 @@ book_interest_references = create_embedding_dict('Interested Type of Books')
95
  import requests
96
 
97
  def fetch_job_listings(job_title):
98
- url = "https://jobs-api14.p.rapidapi.com/v2/list"
99
 
100
- querystring = {
101
- "query": job_title,
102
- "location": "India"
 
 
103
  }
104
 
105
  headers = {
@@ -107,21 +109,22 @@ def fetch_job_listings(job_title):
107
  "X-RapidAPI-Host": "active-jobs-db.p.rapidapi.com"
108
  }
109
 
110
- response = requests.get(url, headers=headers, params=querystring)
111
  job_data = response.json()
112
 
113
- print("RAW RESPONSE:", job_data) # keep for now
114
 
115
- if job_data.get("data"):
116
- job_listings = []
117
- for job in job_data["data"][:5]:
118
- job_listings.append([
119
- job.get("job_title", "N/A"),
120
- job.get("employer_name", "N/A"),
121
- job.get("job_city", "N/A"),
122
- job.get("job_min_salary", "Not specified")
 
123
  ])
124
- return job_listings
125
  else:
126
  return [["No job listings", "found", "for this", "career path"]]
127
 
 
95
  import requests
96
 
97
  def fetch_job_listings(job_title):
98
+ url = "https://active-jobs-db.p.rapidapi.com/active-ats-7d"
99
 
100
+ params = {
101
+ "limit": "10",
102
+ "title_filter": job_title,
103
+ "location_filter": "India",
104
+ "description_type": "text"
105
  }
106
 
107
  headers = {
 
109
  "X-RapidAPI-Host": "active-jobs-db.p.rapidapi.com"
110
  }
111
 
112
+ response = requests.get(url, headers=headers, params=params)
113
  job_data = response.json()
114
 
115
+ print("RAW RESPONSE:", job_data)
116
 
117
+ # ✅ Active Jobs DB returns a LIST, not dict
118
+ if isinstance(job_data, list) and len(job_data) > 0:
119
+ jobs = []
120
+ for job in job_data[:5]:
121
+ jobs.append([
122
+ job.get("title", "N/A"),
123
+ job.get("organization", "N/A"),
124
+ job.get("location", "N/A"),
125
+ job.get("salary_raw", "Not specified")
126
  ])
127
+ return jobs
128
  else:
129
  return [["No job listings", "found", "for this", "career path"]]
130