> 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/web-api/playground.md).

# Web API Playground

了解如何使用 Web API Playground 构建和测试搜索及抓取请求、预览结果并导出可直接使用的代码。

[**Web API Playground**](https://dashboard.oxylabs.io/playground/web-api/search) 是 Oxylabs 仪表板中的一个交互式工具。它可让你无需编写代码即可构建和测试 Web API 请求。

使用 Web API Playground，你可以运行 `/search` 和 `/scrape` 并排运行请求、调整请求参数、切换输出格式、预览结果，并复制你所选语言的可直接使用代码。&#x20;

它旨在用于快速原型开发、探索 API 针对目标返回的内容，以及在将请求添加到项目之前进行验证。

### 谁可以使用？

所有有权访问 Web API 的 Oxylabs 仪表板用户均可使用 Web API Playground。

* **新用户** 可获得 5 美元欢迎额度。
* **现有客户** 可将 Playground 与其常规 API 集成一起使用，作为测试和原型开发环境。

{% hint style="info" %}
Web API Playground 仅用于 **测试和探索** 。对于大批量或自动化工作流，请直接从代码中调用 Web API 端点，并使用为大流量设计的交付模式。
{% endhint %}

## 如何使用它

{% stepper %}
{% step %}

### 访问 Web API Playground

登录到 [Oxylabs 控制面板](https://dashboard.oxylabs.io/) 并打开你的 Web API 产品实例。

<figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2FrHJvPSmZfrSOLJphS6tZ%2FScreenshot%202026-10-20%20at%2016.45.44.png?alt=media&amp;token=eed640cc-f571-4453-adbd-22ea0348655c" alt=""><figcaption></figcaption></figure>

Playground 位于你的 Web API 产品实例概览页面中央。

<figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2F4AoAa4S2z2VY09X8iK0j%2FScreenshot%202026-10-20%20at%2016.48.20.png?alt=media&amp;token=70ad1f9a-4a1a-4da5-ac99-ab0af440736c" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### 选择一个端点

选择 `/search` 以发现针对查询的最新、已排序来源，或者 `/scrape` 从已知 URL 检索干净、结构化的数据。

<figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2FsDA7DFjttru2iSCV2Krz%2FScreenshot%202026-10-20%20at%2016.58.42.png?alt=media&amp;token=a988e1f3-cbc6-4ba4-a4de-857e5787398e" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### 输入详细信息

根据你选择的 Web API Playground 模式，查看下方对应选项卡：

{% tabs %}
{% tab title="搜索" %}
对于 `/search`，输入你要搜索的关键词或短语。

<figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fft12kN4l2j5sjndYBF0M%2FScreenshot%202026-10-20%20at%2017.34.47.png?alt=media&amp;token=055c3b47-e47b-455b-b617-0966f48c6343" alt="" width="440"><figcaption></figcaption></figure>

然后，点击 **选项** 按钮：

<figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Ft2b3BkSILoi0NvlGmNXT%2FScreenshot%202026-10-20%20at%2017.40.45.png?alt=media&amp;token=2b2573c5-b0f6-4fe9-93a8-6343d71d153a" alt="" width="446"><figcaption></figcaption></figure>

* **结果数量（**`max_results`**):**  要返回的自然搜索结果数量 默认： `10`，最大值： `20`.
* **目标本地化（**`location`**):** 可搜索下拉框，接受 2 位 ISO 国家代码（例如， `US`, `DE`, `GB`）以本地化 Web API 搜索结果。
  {% endtab %}

{% tab title="抓取" %}
对于 `/scrape`，输入要抓取的目标页面 URL。

<figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2F8Uw3Otpk7u3H8ud3GGOq%2FScreenshot%202026-10-20%20at%2017.36.30.png?alt=media&amp;token=03374f56-502e-46cd-af8b-22e4667bf092" alt="" width="444"><figcaption></figcaption></figure>

然后，点击 **选项** 按钮：

<figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fc3ktRkEIpVMP4bk0UQNg%2FScreenshot%202026-10-20%20at%2017.53.52.png?alt=media&amp;token=8cd2aa18-3f17-4f02-886d-d6d576f83227" alt="" width="442"><figcaption></figcaption></figure>

<table data-header-hidden><thead><tr><th width="195"></th><th></th></tr></thead><tbody><tr><td><strong>位置（</strong><code>location</code><strong>)</strong></td><td>按国家/地区级别的 IP 地理定向，用于本地化和地理围栏页面访问。</td></tr><tr><td><strong>设备（</strong><code>设备</code><strong>)</strong></td><td>将请求客户端标头和视口模拟配置为 <code>桌面端</code> （默认）或 <code>移动端</code>.</td></tr><tr><td><strong>JS 渲染（</strong><code>run_js</code><strong>)</strong></td><td>启用无头浏览器 JavaScript 执行，用于客户端渲染。</td></tr></tbody></table>

{% hint style="warning" %}
**注意：** JavaScript 渲染会为 `/scrape` 端点请求增加额外的额度消耗。
{% endhint %}

最后，点击 **输出** 按钮来配置交付格式。可选择多种输出格式：

<figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2FX8jhDBpZZZNqd9le8o6K%2FScreenshot%202026-10-20%20at%2018.03.38.png?alt=media&amp;token=79eff283-cd33-4409-b913-cc88596e265c" alt=""><figcaption></figcaption></figure>

<table data-header-hidden><thead><tr><th width="126"></th><th></th></tr></thead><tbody><tr><td>HTML</td><td>返回原始未解析或已渲染的 DOM HTML（默认）</td></tr><tr><td>Markdown</td><td>将页面 DOM 转换为干净、可直接供 LLM 使用的 Markdown，丢弃样板 script/style 标签，是适合 LLM 的输出选项。</td></tr><tr><td>JSON</td><td>返回结构化程序数据。（需要以下任一项 <code>schema</code> 或 <code>prompt</code>基于的提取规则。了解两种提取模式的更多信息，请参阅 <a href="https://developers.oxylabs.io/products/cn/web-api/scrape/ai-jie-xi.md">AI 解析</a> 页面。）</td></tr><tr><td>截图</td><td>捕获完整的页面可视化渲染。需要 JS 渲染，额外收费。</td></tr></tbody></table>

选择多个选项会将每个值追加到有效负载的 `输出` 数组（例如 `"output": ["html", "md"]`).
{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

### 运行请求

点击 **箭头按钮** 并在 **输出** 下面的章节。

<figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fg2blsFgN3IDDPiZvwQAi%2FScreenshot%202026-10-20%20at%2018.19.09.png?alt=media&amp;token=938fd0e0-2eff-4c02-9ad2-1b6c83d4f7ed" alt=""><figcaption></figcaption></figure>

在这里，你可以预览结果、评估响应速度，并以所选输出格式检查或下载结果输出。
{% endstep %}

{% step %}

### 导出

如果你对结果满意，请切换到 **请求** 选项卡，在那里你可以复制所生成的代码，使用你偏好的语言，并将其用于脚本或应用程序。

如果你想将 Web API 集成到你的 AI 智能体或编码助手中，你也可以选择 **复制到智能体** 选项，它可通过单个提示将 Web API 与你的智能体集成。

<figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2FARyOuDiUswjxOeabPTdv%2FScreenshot%202026-10-20%20at%2018.30.12.png?alt=media&amp;token=8421a154-5058-4777-aa83-c908d2dbe288" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
导出的代码会使用你的 API 密钥进行身份验证。请将其保留在服务器端，切勿提交到源代码管理中。请参阅 [身份验证](https://developers.oxylabs.io/products/cn/web-api/shen-fen-yan-zheng.md).&#x20;
{% endhint %}
{% endstep %}
{% endstepper %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.oxylabs.io/products/cn/web-api/playground.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
