Firoj112 commited on
Commit
8e168dd
·
verified ·
1 Parent(s): 56cc2bc

Update tools/scrape_text.py

Browse files
Files changed (1) hide show
  1. tools/scrape_text.py +4 -4
tools/scrape_text.py CHANGED
@@ -7,10 +7,10 @@ class ScrapeTextTool(Tool):
7
  name = "scrape_text"
8
  description = "Scrapes text or table data from elements matching a CSS selector on the current page."
9
  inputs = {
10
- "selector": {"type": "str", "default": "p", "description": "CSS selector to target elements"},
11
- "extract_table": {"type": "bool", "default": False, "description": "If True, extract table data as JSON"}
12
  }
13
- output_type = "str"
14
 
15
  def __init__(self, driver):
16
  self.driver = driver
@@ -40,4 +40,4 @@ class ScrapeTextTool(Tool):
40
  text_list = [element.text.strip() for element in elements if element.text.strip()]
41
  return "\n".join(text_list) if text_list else "No text found for selector"
42
  except Exception as e:
43
- return f"Failed to scrape with selector {selector}: {str(e)}"
 
7
  name = "scrape_text"
8
  description = "Scrapes text or table data from elements matching a CSS selector on the current page."
9
  inputs = {
10
+ "selector": {"type": "string", "default": "p", "description": "CSS selector to target elements"},
11
+ "extract_table": {"type": "boolean", "default": False, "description": "If True, extract table data as JSON"}
12
  }
13
+ output_type = "string"
14
 
15
  def __init__(self, driver):
16
  self.driver = driver
 
40
  text_list = [element.text.strip() for element in elements if element.text.strip()]
41
  return "\n".join(text_list) if text_list else "No text found for selector"
42
  except Exception as e:
43
+ return f"Failed to scrape with selector {selector}: {str(e)}"