Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,7 +24,6 @@ def search_jobs_tool(query: str, location: str, limit: int = 10, salary: str = N
|
|
| 24 |
dict: Contains a list of jobs with title, company, location, and url.
|
| 25 |
"""
|
| 26 |
base_url = "https://ca.indeed.com/jobs?"
|
| 27 |
-
|
| 28 |
params = {
|
| 29 |
"q": query,
|
| 30 |
"l": location,
|
|
@@ -33,9 +32,18 @@ def search_jobs_tool(query: str, location: str, limit: int = 10, salary: str = N
|
|
| 33 |
|
| 34 |
url = base_url + urlencode(params)
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
try:
|
| 37 |
scraper = cloudscraper.create_scraper()
|
| 38 |
-
response = scraper.get(url)
|
| 39 |
response.raise_for_status()
|
| 40 |
|
| 41 |
soup = BeautifulSoup(response.text, "html.parser")
|
|
|
|
| 24 |
dict: Contains a list of jobs with title, company, location, and url.
|
| 25 |
"""
|
| 26 |
base_url = "https://ca.indeed.com/jobs?"
|
|
|
|
| 27 |
params = {
|
| 28 |
"q": query,
|
| 29 |
"l": location,
|
|
|
|
| 32 |
|
| 33 |
url = base_url + urlencode(params)
|
| 34 |
|
| 35 |
+
headers = {
|
| 36 |
+
"User-Agent": (
|
| 37 |
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
|
| 38 |
+
"AppleWebKit/537.36 (KHTML, like Gecko) "
|
| 39 |
+
"Chrome/114.0.0.0 Safari/537.36"
|
| 40 |
+
),
|
| 41 |
+
"Accept-Language": "en-US,en;q=0.9",
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
try:
|
| 45 |
scraper = cloudscraper.create_scraper()
|
| 46 |
+
response = scraper.get(url, headers=headers)
|
| 47 |
response.raise_for_status()
|
| 48 |
|
| 49 |
soup = BeautifulSoup(response.text, "html.parser")
|