lib/crewai-tools/src/crewai_tools/aws/bedrock/browser/README.md
This toolkit provides a set of tools for interacting with web browsers through AWS Bedrock Browser. It enables your CrewAI agents to navigate websites, extract content, click elements, and more.
Ensure you have the necessary dependencies:
uv add crewai-tools bedrock-agentcore beautifulsoup4 playwright nest-asyncio
from crewai import Agent, Task, Crew, LLM
from crewai_tools.aws.bedrock.browser import create_browser_toolkit
# Create the browser toolkit
toolkit, browser_tools = create_browser_toolkit(region="us-west-2")
# Create the Bedrock LLM
llm = LLM(
model="bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0",
region_name="us-west-2",
)
# Create a CrewAI agent that uses the browser tools
research_agent = Agent(
role="Web Researcher",
goal="Research and summarize web content",
backstory="You're an expert at finding information online.",
tools=browser_tools,
llm=llm
)
# Create a task for the agent
research_task = Task(
description="Navigate to https://example.com and extract all text content. Summarize the main points.",
expected_output="A list of bullet points containing the most important information on https://example.com. Plus, a description of the tool calls used, and actions performed to get to the page.",
agent=research_agent
)
# Create and run the crew
crew = Crew(
agents=[research_agent],
tasks=[research_task]
)
result = crew.kickoff()
print(f"\n***Final result:***\n\n{result}")
# Clean up browser resources when done
toolkit.sync_cleanup()
The toolkit provides the following tools:
navigate_browser - Navigate to a URLclick_element - Click on an element using CSS selectorsextract_text - Extract all text from the current webpageextract_hyperlinks - Extract all hyperlinks from the current webpageget_elements - Get elements matching a CSS selectornavigate_back - Navigate to the previous pagecurrent_webpage - Get information about the current webpageimport asyncio
from crewai import Agent, Task, Crew, LLM
from crewai_tools.aws.bedrock.browser import create_browser_toolkit
async def main():
# Create the browser toolkit with specific AWS region
toolkit, browser_tools = create_browser_toolkit(region="us-west-2")
tools_by_name = toolkit.get_tools_by_name()
# Create the Bedrock LLM
llm = LLM(
model="bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0",
region_name="us-west-2",
)
# Create agents with specific tools
navigator_agent = Agent(
role="Navigator",
goal="Find specific information across websites",
backstory="You navigate through websites to locate information.",
tools=[
tools_by_name["navigate_browser"],
tools_by_name["click_element"],
tools_by_name["navigate_back"]
],
llm=llm
)
content_agent = Agent(
role="Content Extractor",
goal="Extract and analyze webpage content",
backstory="You extract and analyze content from webpages.",
tools=[
tools_by_name["extract_text"],
tools_by_name["extract_hyperlinks"],
tools_by_name["get_elements"]
],
llm=llm
)
# Create tasks for the agents
navigation_task = Task(
description="Navigate to https://example.com, then click on the the 'More information...' link.",
expected_output="The status of the tool calls for this task.",
agent=navigator_agent,
)
extraction_task = Task(
description="Extract all text from the current page and summarize it.",
expected_output="The summary of the page, and a description of the tool calls used, and actions performed to get to the page.",
agent=content_agent,
)
# Create and run the crew
crew = Crew(
agents=[navigator_agent, content_agent],
tasks=[navigation_task, extraction_task]
)
result = await crew.kickoff_async()
# Clean up browser resources when done
toolkit.sync_cleanup()
return result
if __name__ == "__main__":
result = asyncio.run(main())
print(f"\n***Final result:***\n\n{result}")