ScrapeWebsiteTool

我们仍在努力改进这些工具,因此未来可能会出现意外行为或变更。

描述

一个旨在提取和读取指定网站内容的工具。它能够通过发出 HTTP 请求并解析接收到的 HTML 内容来处理各种类型的网页。此工具对于网页抓取任务、数据收集或从网站提取特定信息特别有用。

安装

安装 crewai_tools 包

pip install 'crewai[tools]'

示例

from crewai_tools import ScrapeWebsiteTool

# To enable scrapping any website it finds during it's execution
tool = ScrapeWebsiteTool()

# Initialize the tool with the website URL, 
# so the agent can only scrap the content of the specified website
tool = ScrapeWebsiteTool(website_url='https://www.example.com')

# Extract the text from the site
text = tool.run()
print(text)

参数

参数类型描述
website_url字符串必填 要读取文件的网站 URL。这是该工具的主要输入,用于指定应抓取和读取哪个网站的内容。