> ## 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.

# Google搜索

**GoogleSearch** 使 Agent 能够执行网络爬取和抓取任务。

## 先决条件

以下示例需要 `googlesearch` 和 `pycountry` 库。

```shell theme={null}
pip install -U googlesearch-python pycountry
```

## 示例

下面的 Agent 将在 Google 上搜索关于“Mistral AI”的最新新闻：

```python cookbook/tools/googlesearch_tools.py theme={null}
from agno.agent import Agent
from agno.tools.googlesearch import GoogleSearchTools

agent = Agent(
    tools=[GoogleSearchTools()],
    description="你是一个新闻代理，帮助用户找到最新新闻。",
    instructions=[
        "根据用户提供的话题，回应4条关于该话题的最新新闻。",
        "搜索10条新闻并选择前4条不重复的。",
        "使用英语和法语进行搜索。",
    ],
    show_tool_calls=True,
    debug_mode=True,
)

agent.print_response("Mistral AI", markdown=True)
```

## Toolkit 参数

| 参数                  | 类型    | 默认值    | 描述              |
| ------------------- | ----- | ------ | --------------- |
| `fixed_max_results` | `int` | `None` | 可选的固定最大返回结果数。   |
| `fixed_language`    | `str` | `None` | 可选的请求固定语言。      |
| `headers`           | `Any` | `None` | 可选的要包含在请求中的标头。  |
| `proxy`             | `str` | `None` | 可选的用于请求的代理。     |
| `timeout`           | `int` | `None` | 可选的请求超时时间，单位为秒。 |

## Toolkit 函数

| 函数              | 描述                                                                                                                       |
| --------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `google_search` | 搜索 Google 指定的查询。参数包括用于搜索词的 `query`，用于最大结果数的 `max_results`（默认为 5），以及用于搜索结果语言的 `language`（默认为 "en"）。将搜索结果作为 JSON 格式的字符串返回。 |

## 开发者资源

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