> ## Documentation Index
> Fetch the complete documentation index at: https://ikun.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# AgentQL

**AgentQLTools** 允许 Agent 使用 AgentQL API 来浏览和抓取网站。

## 先决条件

以下示例需要 `agentql` 库和一个 API 令牌，您可以在 [AgentQL](https://agentql.com/) 获取。

```shell theme={null}
pip install -U agentql
```

```shell theme={null}
export AGENTQL_API_KEY=***
```

## 示例

下面的 Agent 将打开一个网页浏览器并抓取页面上的所有文本。

```python cookbook/tools/agentql_tools.py theme={null}
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.agentql import AgentQLTools

agent = Agent(
    model=OpenAIChat(id="gpt-4o"), tools=[AgentQLTools()], show_tool_calls=True
)

agent.print_response("https://docs.agno.com/introduction", markdown=True)
```

<Note>
  AgentQL 将打开一个浏览器实例（请勿关闭），并抓取该网站上的内容。
</Note>

## Toolkit 参数

| 参数              | 类型     | 默认值    | 描述               |
| :-------------- | :----- | :----- | :--------------- |
| `api_key`       | `str`  | `None` | AgentQL 的 API 密钥 |
| `scrape`        | `bool` | `True` | 是否使用抓取文本工具       |
| `agentql_query` | `str`  | `None` | 自定义 AgentQL 查询   |

## Toolkit 函数

| 函数                      | 描述                           |
| :---------------------- | :--------------------------- |
| `scrape_website`        | 用于抓取网页上的所有文本                 |
| `custom_scrape_website` | 使用自定义 `agentql_query` 抓取网页内容 |

## 开发者资源

* 查看 [Tools](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/agentql.py)
* 查看 [Cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/tools/agentql_tools.py)
