Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -45,11 +45,10 @@ def search_jobs_tool(query: str, location: str, limit: int = 10, salary: str = N
|
|
| 45 |
response.raise_for_status()
|
| 46 |
|
| 47 |
soup = BeautifulSoup(response.text, "html.parser")
|
| 48 |
-
jobs = []
|
| 49 |
-
|
| 50 |
cards = soup.find_all("article", class_="resultJobItem")
|
| 51 |
|
| 52 |
-
|
|
|
|
| 53 |
title_elem = card.find("a", attrs={"data-testid": "result-job-title"})
|
| 54 |
company_elem = card.find("div", attrs={"data-testid": "result-employer"})
|
| 55 |
location_elem = card.find("div", attrs={"data-testid": "result-location"})
|
|
@@ -65,7 +64,7 @@ def search_jobs_tool(query: str, location: str, limit: int = 10, salary: str = N
|
|
| 65 |
}
|
| 66 |
jobs.append(job)
|
| 67 |
|
| 68 |
-
return {"jobs": jobs}
|
| 69 |
|
| 70 |
except Exception as e:
|
| 71 |
return {"error": str(e)}
|
|
@@ -74,16 +73,6 @@ def search_jobs_tool(query: str, location: str, limit: int = 10, salary: str = N
|
|
| 74 |
def search_jobs_ui(query, location, limit=10, salary=None, job_type=None):
|
| 75 |
"""
|
| 76 |
Interface function for displaying job search results in markdown format.
|
| 77 |
-
|
| 78 |
-
Args:
|
| 79 |
-
query (str): Job title or keyword.
|
| 80 |
-
location (str): Location to search in.
|
| 81 |
-
limit (int): Number of results to return.
|
| 82 |
-
salary (str, optional): Placeholder argument (not used).
|
| 83 |
-
job_type (str, optional): Placeholder argument (not used).
|
| 84 |
-
|
| 85 |
-
Returns:
|
| 86 |
-
str: Markdown-formatted job listings or error message.
|
| 87 |
"""
|
| 88 |
result = search_jobs_tool(query, location, limit, salary, job_type)
|
| 89 |
|
|
|
|
| 45 |
response.raise_for_status()
|
| 46 |
|
| 47 |
soup = BeautifulSoup(response.text, "html.parser")
|
|
|
|
|
|
|
| 48 |
cards = soup.find_all("article", class_="resultJobItem")
|
| 49 |
|
| 50 |
+
jobs = []
|
| 51 |
+
for card in cards:
|
| 52 |
title_elem = card.find("a", attrs={"data-testid": "result-job-title"})
|
| 53 |
company_elem = card.find("div", attrs={"data-testid": "result-employer"})
|
| 54 |
location_elem = card.find("div", attrs={"data-testid": "result-location"})
|
|
|
|
| 64 |
}
|
| 65 |
jobs.append(job)
|
| 66 |
|
| 67 |
+
return {"jobs": jobs[:limit]} # Apply limit after scraping all
|
| 68 |
|
| 69 |
except Exception as e:
|
| 70 |
return {"error": str(e)}
|
|
|
|
| 73 |
def search_jobs_ui(query, location, limit=10, salary=None, job_type=None):
|
| 74 |
"""
|
| 75 |
Interface function for displaying job search results in markdown format.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
"""
|
| 77 |
result = search_jobs_tool(query, location, limit, salary, job_type)
|
| 78 |
|