Spaces:
Runtime error
Runtime error
HarshEra commited on
new tool (jobs scraping tool)
Browse files
app.py
CHANGED
|
@@ -4,6 +4,8 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
|
@@ -59,11 +61,46 @@ def finance_management_plan(budget: float, habits: str, goal: str, period: str)
|
|
| 59 |
f"{new_habits_str}\n"
|
| 60 |
f"This will help you stay on track with your financial goals."
|
| 61 |
)
|
| 62 |
-
|
| 63 |
-
|
| 64 |
# Example usage:
|
| 65 |
print(finance_management_plan(1000.0, "Monday: $50, Tuesday: $30, Wednesday: $40, Thursday: $20, Friday: $60, Saturday: $80, Sunday: $70", "Save $500 for a vacation", "month"))
|
| 66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
@tool
|
| 68 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 69 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
import csv
|
| 8 |
+
from jobspy import scrape_jobs
|
| 9 |
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
|
|
|
| 61 |
f"{new_habits_str}\n"
|
| 62 |
f"This will help you stay on track with your financial goals."
|
| 63 |
)
|
|
|
|
|
|
|
| 64 |
# Example usage:
|
| 65 |
print(finance_management_plan(1000.0, "Monday: $50, Tuesday: $30, Wednesday: $40, Thursday: $20, Friday: $60, Saturday: $80, Sunday: $70", "Save $500 for a vacation", "month"))
|
| 66 |
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
@tool
|
| 70 |
+
def webscraping_jobs(search_term: str, location: str, results_wanted: int = 20, hours_old: int = 72, country_indeed: str = 'USA') -> str:
|
| 71 |
+
"""
|
| 72 |
+
A tool that scrapes job listings from multiple websites based on jobspy library.
|
| 73 |
+
|
| 74 |
+
Args:
|
| 75 |
+
search_term (str): The job title or keywords to search for (e.g., 'software engineer').
|
| 76 |
+
location (str): The location to search for jobs (e.g., 'San Francisco, CA').
|
| 77 |
+
results_wanted (int, optional): Number of results to retrieve (default is 20).
|
| 78 |
+
hours_old (int, optional): Maximum age of job postings in hours (default is 72).
|
| 79 |
+
country_indeed (str, optional): Country filter for Indeed searches (default is 'USA').
|
| 80 |
+
|
| 81 |
+
Returns:
|
| 82 |
+
str: A message with the number of jobs found and saves results to 'jobs.csv'.
|
| 83 |
+
"""
|
| 84 |
+
|
| 85 |
+
jobs = scrape_jobs(
|
| 86 |
+
site_name=["indeed", "LinkedIn", "google", "bayt", "naukri","Tanitjobs"], # other "zip_recruiter", "glassdoor",
|
| 87 |
+
search_term=search_term,
|
| 88 |
+
google_search_term=f"{search_term} jobs near {location} since yesterday",
|
| 89 |
+
location=location,
|
| 90 |
+
results_wanted=results_wanted,
|
| 91 |
+
hours_old=hours_old,
|
| 92 |
+
country_indeed=country_indeed,
|
| 93 |
+
)
|
| 94 |
+
|
| 95 |
+
if jobs.empty:
|
| 96 |
+
return f"No jobs found for '{search_term}' in '{location}'."
|
| 97 |
+
|
| 98 |
+
# Save results to CSV
|
| 99 |
+
jobs.to_csv("jobs.csv", quoting=csv.QUOTE_NONNUMERIC, escapechar="\\", index=False)
|
| 100 |
+
|
| 101 |
+
return f"Found {len(jobs)} jobs for '{search_term}' in '{location}'. Results saved to 'jobs.csv'."
|
| 102 |
+
|
| 103 |
+
|
| 104 |
@tool
|
| 105 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 106 |
"""A tool that fetches the current local time in a specified timezone.
|