Spaces:
Runtime error
Runtime error
Update scraper.py
Browse files- 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
|
| 105 |
global current_key_index
|
| 106 |
-
if not
|
| 107 |
-
api_key =
|
| 108 |
-
current_key_index = (current_key_index + 1) % len(
|
| 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 |
-
|
|
|
|
| 218 |
if not api_key: return None
|
| 219 |
|
| 220 |
-
#
|
| 221 |
-
url = "https://api.
|
| 222 |
|
| 223 |
headers = {
|
| 224 |
"Content-Type": "application/json",
|
| 225 |
"Authorization": f"Bearer {api_key}"
|
| 226 |
}
|
| 227 |
|
| 228 |
-
#
|
| 229 |
payload = {
|
| 230 |
-
"model": "llama-3.1-8b-instant", #
|
| 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 |
-
|
|
|
|
| 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
|