OppaAI commited on
Commit
a9180ef
·
verified ·
1 Parent(s): 4761c74

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -1,4 +1,3 @@
1
- import os
2
  import gradio as gr
3
  import cloudscraper
4
  from bs4 import BeautifulSoup
@@ -24,6 +23,7 @@ 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
  params = {
28
  "q": query,
29
  "l": location,
@@ -31,7 +31,6 @@ def search_jobs_tool(query: str, location: str, limit: int = 10, salary: str = N
31
  }
32
 
33
  url = base_url + urlencode(params)
34
-
35
  headers = {
36
  "User-Agent": (
37
  "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
@@ -43,7 +42,7 @@ def search_jobs_tool(query: str, location: str, limit: int = 10, salary: str = N
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")
@@ -100,8 +99,8 @@ app = gr.Interface(
100
  gr.Textbox(label="Job Type (optional, ignored)")
101
  ],
102
  outputs="markdown",
103
- title="Indeed Job Search (with BeautifulSoup + Cloudscraper) + FastMCP",
104
- description="Search jobs by scraping Indeed.ca using cloudscraper and BeautifulSoup. Results sorted by most recent."
105
  )
106
 
107
  if __name__ == "__main__":
 
 
1
  import gradio as gr
2
  import cloudscraper
3
  from bs4 import BeautifulSoup
 
23
  dict: Contains a list of jobs with title, company, location, and url.
24
  """
25
  base_url = "https://ca.indeed.com/jobs?"
26
+
27
  params = {
28
  "q": query,
29
  "l": location,
 
31
  }
32
 
33
  url = base_url + urlencode(params)
 
34
  headers = {
35
  "User-Agent": (
36
  "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
 
42
 
43
  try:
44
  scraper = cloudscraper.create_scraper()
45
+ response = scraper.get(url, headers=headers, timeout=15)
46
  response.raise_for_status()
47
 
48
  soup = BeautifulSoup(response.text, "html.parser")
 
99
  gr.Textbox(label="Job Type (optional, ignored)")
100
  ],
101
  outputs="markdown",
102
+ title="Indeed Job Search (with cloudscraper) + FastMCP",
103
+ description="Search jobs by scraping Indeed.ca using cloudscraper and BeautifulSoup."
104
  )
105
 
106
  if __name__ == "__main__":