File tree 1 file changed +13
-0
lines changed
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 20
20
- 'input_text': Input text into an element
21
21
- 'screenshot': Capture a screenshot
22
22
- 'get_html': Get page HTML content
23
+ - 'get_text': Get text content of the page
24
+ - 'read_links': Get all links on the page
23
25
- 'execute_js': Execute JavaScript code
24
26
- 'scroll': Scroll the page
25
27
- 'switch_tab': Switch to a specific tab
@@ -43,6 +45,7 @@ class BrowserUseTool(BaseTool):
43
45
"input_text" ,
44
46
"screenshot" ,
45
47
"get_html" ,
48
+ "get_text" ,
46
49
"execute_js" ,
47
50
"scroll" ,
48
51
"switch_tab" ,
@@ -180,6 +183,16 @@ async def execute(
180
183
truncated = html [:2000 ] + "..." if len (html ) > 2000 else html
181
184
return ToolResult (output = truncated )
182
185
186
+ elif action == "get_text" :
187
+ text = await context .execute_javascript ("document.body.innerText" )
188
+ return ToolResult (output = text )
189
+
190
+ elif action == "read_links" :
191
+ links = await context .execute_javascript (
192
+ "document.querySelectorAll('a[href]').forEach((elem) => {if (elem.innerText) {console.log(elem.innerText, elem.href)}})"
193
+ )
194
+ return ToolResult (output = links )
195
+
183
196
elif action == "execute_js" :
184
197
if not script :
185
198
return ToolResult (
You can’t perform that action at this time.
0 commit comments