> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/products/cn/ai-studio/ai-search.md).

# AI-Search

## 概述

该 [**AI-Search**](https://aistudio.oxylabs.io/apps/search) 由 [**Oxylabs AI Studio**](https://aistudio.oxylabs.io/) 是一个网络搜索工具，允许开发者检索搜索结果，可选地抓取这些结果，并轻松处理 JavaScript 渲染内容。它旨在充当一个智能搜索代理，将相关信息直接提取到你的 Python 应用中，从而简化流程。

无论你需要的是简单的 URL 列表，还是深度内容提取，AI Search 都能消除从零开始构建自定义搜索抓取器的复杂性。

## 主要功能

* **使用普通英文查询网页：** 只需用自然语言提供你的搜索查询，让代理来完成繁重工作。
* **控制搜索结果数量：** 轻松精确地定义你想获取多少结果。
* **可选地抓取结果页面内容：** 自动直接从返回的搜索结果中抓取并提取内容片段。
* **动态内容的 Python 渲染：** 启用渲染，以无缝处理并从大量 JavaScript 的网站中提取数据。

## 工作原理

要使用搜索代理，请按照以下简单步骤：

1. **输入搜索查询** ，即你想要查找的内容。
2. **设置所需的结果数量** ，以限制或扩展你的搜索范围。
3. **切换内容抓取和 JS 渲染** ，具体取决于你是否需要深度内容提取，还是只需要 URL 和标题。

### 安装

开始前，请确保你已拥有 API key（或 [获取免费试用](https://aistudio.oxylabs.io/register) 使用 **1,000 credits**）并已 `安装 Python 3.10+。你可以安装` 以下示例演示了如何使用 `oxylabs-ai-studio` 软件包，使用 pip：

```bash
pip install oxylabs-ai-studio
```

### 代码示例（Python）

以下示例演示如何使用 `AI-Seaerch` 代理进行数据检索场景。

```python
from oxylabs_ai_studio.apps.ai_search import AiSearch

search = AiSearch(api_key="<API_KEY>")

query = "lasagna recipes"
result = search.search(
    query=query,
    limit=5,
    render_javascript=False,
    return_content=True,
)
print(result.data)

# Or for fast search
result = search.instant_search(
    query=query,
    limit=10,
)
print(result.data)
```

了解更多关于 AI-Search 和 Oxylabs AI Studio Python SDK 的信息，请参阅我们的 [PyPI 存储库](https://pypi.org/project/oxylabs-ai-studio/)。您也可以查看我们的 [AI Studio JavaScript SDK](https://github.com/oxylabs/oxylabs-ai-studio-js) 指南，适用于 JS 用户。

### 请求参数

| 参数                                                   | 说明                   | 默认值     |
| ---------------------------------------------------- | -------------------- | ------- |
| <mark style="background-color:green;">`query`</mark> | 要搜索的内容               | –       |
| `limit`                                              | 返回结果的最大数量（最大值：50）    | 10      |
| `render_javascript`                                  | 启用 JavaScript 渲染     | `False` |
| `return_content`                                     | 是否在结果中返回 Markdown 内容 | `True`  |
| `geo_location`                                       | ISO2 格式的代理位置         | –       |

&#x20;    – 必填参数

**注意：** 当 `limit <= 10` 和 `return_content=False`时，搜索会自动使用即时端点（`/search/instant`），它无需轮询即可立即返回结果，提供更快的响应时间。

{% hint style="info" %}
**注意：** 当 `limit <= 10` 和 `return_content=False`时，搜索会自动使用即时端点（`/search/instant`），它无需轮询即可立即返回结果，提供更快的响应时间。
{% endhint %}

即时搜索支持的参数：

| 参数                                                   | 说明                                                                                        | 默认值  |
| ---------------------------------------------------- | ----------------------------------------------------------------------------------------- | ---- |
| <mark style="background-color:green;">`query`</mark> | 要搜索的内容                                                                                    | –    |
| `limit`                                              | 要返回的搜索结果最大数量（最大值： `10`)                                                                   | `10` |
| `geo_location`                                       | Google 对该位置的规范名称。查看更多 [此处](https://developers.google.com/google-ads/api/data/geotargets). | –    |

&#x20;    – 必填参数

### 输出示例

```python
[
  {
    "url": "https://www.spendwithpennies.com/easy-homemade-lasagna/",
    "title": "Easy Homemade Lasagna Recipe - Spend With Pennies",
    "description": "Rating 5.0 (3,349) · 1 hr 45 min This is the best LASAGNA RECIPE! Pasta, an easy meat sauce, and ricotta cheese are layered and then topped with more cheese before baking.",
    "content": null
  },
  {
    "url": "https://www.simplyrecipes.com/recipes/lasagna/",
    "title": "The Best Homemade Lasagna - Simply Recipes",
    "description": "Rating 4.9 (115) · 1 hr 45 min This classic lasagna recipe is made with an easy meat sauce as the base. Layer the sauce with noodles and cheese, then bake until bubbly!",
    "content": null
  },
  {
    "url": "https://www.seriouseats.com/12-lasagna-recipes-11808722",
    "title": "12 Must-Try Lasagna Recipes Featuring Crispy Edges and Gooey ...",
    "description": "Whether you have a taste for meaty classics like a lasagna alla Bolognese or an indulgent creamy vegetarian spinach lasagna, we've rounded up our favorite ...",
    "content": null
  },
  {
    "url": "https://bakerbynature.com/the-best-homemade-lasagna-recipe/",
    "title": "The Best Easy Homemade Lasagna Recipe - Baker by Nature",
    "description": "Rating 5.0 (71) · 2 hr 45 min Dec 12, 2025 · This is the ONLY lasagna recipe you'll ever need... from perfectly cooked noodles to rich tomato sauce and layers of cheese.",
    "content": null
  },
  {
    "url": "https://www.allrecipes.com/recipe/23600/worlds-best-lasagna/",
    "title": "World's Best Lasagna Recipe (with Video) - Allrecipes",
    "description": "Rating 4.8 (20,950) · 3 hr 15 min Feb 5, 2026 · This lasagna recipe from John Chandler is our most popular recipe! With sausage, ground beef, basil, and 3 types of cheese, it lives up to ...",
    "content": null
  }
]
```

## 实际用例

AI-Search 可应用于各种各样的数据发现和收集任务：

1. **搜索某个主题的最新新闻或文章 –** 快速收集最新信息、标题和摘要。
2. **发现书籍、电影或产品 –** 检索符合特定条件或评论的条目列表。
3. **研究竞争性产品 –** 查找并分析竞争对手的定价、功能和市场定位。
4. **从多个网站汇总行业更新 –** 将相关的行业变化和趋势整理成一个统一、结构化的信息流。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers.oxylabs.io/products/cn/ai-studio/ai-search.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
