Crawl4aiTools 使 Agent 能够使用 Crawl4ai 库执行网络爬虫和抓取任务。

先决条件

以下示例需要 crawl4ai 库。

pip install -U crawl4ai

示例

下面的 Agent 将抓取 https://github.com/agno-agi/agno 页面的内容:

cookbook/tools/crawl4ai_tools.py
from agno.agent import Agent
from agno.tools.crawl4ai import Crawl4aiTools

agent = Agent(tools=[Crawl4aiTools(max_length=None)], show_tool_calls=True)
agent.print_response("告诉我关于 https://github.com/agno-agi/agno 的信息。")

Toolkit 参数

参数类型默认值描述
max_lengthint1000指定要返回的网页文本的最大长度。

Toolkit 函数

函数描述
web_crawler使用 crawl4ai 的 WebCrawler 抓取网站。参数包括用于抓取的 URL 的 ‘url’ 和用于限制提取内容长度的可选 ‘max_length’。‘max_length’ 的默认值为 1000。

开发者资源