shelby102503 commited on
Commit
3d6ceea
·
verified ·
1 Parent(s): 8cf4389

Update scraper.py

Browse files
Files changed (1) hide show
  1. scraper.py +12 -10
scraper.py CHANGED
@@ -101,11 +101,11 @@ def make_hireskys_link(original_url):
101
  # 4. Wapis naya VIP link banao
102
  new_query = urlencode(query_params, doseq=True)
103
  return urlunparse((parsed.scheme, parsed.netloc, parsed.path, parsed.params, new_query, parsed.fragment))
104
- def get_grok_key():
105
  global current_key_index
106
- if not GROK_API_KEYS: return None
107
- api_key = GROK_API_KEYS[current_key_index]
108
- current_key_index = (current_key_index + 1) % len(GROK_API_KEYS)
109
  return api_key
110
 
111
  def ai_process_job_safe(title, raw_html, raw_location):
@@ -214,20 +214,21 @@ def ai_process_job_safe(title, raw_html, raw_location):
214
 
215
  for attempt in range(max_retries):
216
  try:
217
- api_key = get_grok_key()
 
218
  if not api_key: return None
219
 
220
- # Grok (xAI) API Endpoint
221
- url = "https://api.x.ai/v1/chat/completions"
222
 
223
  headers = {
224
  "Content-Type": "application/json",
225
  "Authorization": f"Bearer {api_key}"
226
  }
227
 
228
- # Grok ko JSON format laazmi chahiye hota hai isliye system prompt aur response_format set karenge
229
  payload = {
230
- "model": "llama-3.1-8b-instant", # ya "grok-beta" agar sasta wala model use karna hai
231
  "messages": [
232
  {"role": "system", "content": "You are a Strict Job Data Auditor. Always respond in valid JSON format."},
233
  {"role": "user", "content": prompt}
@@ -258,7 +259,8 @@ def ai_process_job_safe(title, raw_html, raw_location):
258
  return data
259
 
260
  except Exception as e:
261
- print(f"❌ Grok Error Attempt {attempt + 1}: {e}")
 
262
  time.sleep(base_wait * (attempt + 1))
263
 
264
  return None
 
101
  # 4. Wapis naya VIP link banao
102
  new_query = urlencode(query_params, doseq=True)
103
  return urlunparse((parsed.scheme, parsed.netloc, parsed.path, parsed.params, new_query, parsed.fragment))
104
+ def get_groq_key():
105
  global current_key_index
106
+ if not GROQ_API_KEYS: return None
107
+ api_key = GROQ_API_KEYS[current_key_index]
108
+ current_key_index = (current_key_index + 1) % len(GROQ_API_KEYS)
109
  return api_key
110
 
111
  def ai_process_job_safe(title, raw_html, raw_location):
 
214
 
215
  for attempt in range(max_retries):
216
  try:
217
+ # Function ka naam get_grok_key se get_groq_key kar diya hai
218
+ api_key = get_groq_key()
219
  if not api_key: return None
220
 
221
+ # Groq ka Asli API Endpoint
222
+ url = "https://api.groq.com/openai/v1/chat/completions"
223
 
224
  headers = {
225
  "Content-Type": "application/json",
226
  "Authorization": f"Bearer {api_key}"
227
  }
228
 
229
+ # Groq payload
230
  payload = {
231
+ "model": "llama-3.1-8b-instant", # Ye model bilkul sahi hai
232
  "messages": [
233
  {"role": "system", "content": "You are a Strict Job Data Auditor. Always respond in valid JSON format."},
234
  {"role": "user", "content": prompt}
 
259
  return data
260
 
261
  except Exception as e:
262
+ # Error message mein bhi Groq kar diya
263
+ print(f"❌ Groq Error Attempt {attempt + 1}: {e}")
264
  time.sleep(base_wait * (attempt + 1))
265
 
266
  return None