# 快速入门：网页爬虫API

Oxylabs [网页爬虫API](https://oxylabs.io/products/scraper-api/web) 是一个一体化解决方案，可自动处理代理轮换、JavaScript 渲染和反机器人系统。本指南将带你从空白终端开始，仅用几分钟即可获取实时网页数据。

按照以下详细步骤操作，或观看简短的视频演示：

{% embed url="<https://www.youtube.com/watch?t=2s&v=WOD0mZnu-j0>" %}

{% stepper %}
{% step %}

### 设置和凭证

在发送第一个请求之前，你需要先授权访问：

1. **创建账户：** 在此处注册： [Oxylabs 控制面板](https://dashboard.oxylabs.io/).
2. **选择套餐：** 选择用于测试的免费试用，或直接订阅。
3. **创建 API 用户：** 前往左侧的“网页爬虫API”部分，并选择“Users”标签。
4. **保存你的凭证：** 所有请求都需要使用这些专用 API 凭证（不是你的控制面板登录信息）。
   {% endstep %}

{% step %}

### 你的第一个请求

\`the\` `universal` source 适用于任何公开网站。打开终端并运行此命令来抓取我们的沙盒站点：

```bash
curl --user 'USERNAME:PASSWORD' \
'https://realtime.oxylabs.io/v1/queries' \
-H 'Content-Type: application/json' \
-d '{
    "source": "universal",
    "url": "https://sandbox.oxylabs.io/products"
}'
```

{% endstep %}

{% step %}

### 获取结构化数据

如果你抓取的是受支持的域名（如 Amazon 或 Google），API 可以返回结构化 JSON，而不是原始 HTML。只需将 `source` 设置为专用目标，并使用 `"parse": true`。例如，让我们抓取一个 Amazon 商品：

```bash
curl 'https://realtime.oxylabs.io/v1/queries' \
--user "USERNAME:PASSWORD" \
-H "Content-Type: application/json" \
-d '{
    "source": "amazon_product", 
    "query": "B07FZ8S74R", 
    "parse": true
}'
```

{% endstep %}
{% endstepper %}

### 关键参数

这些是最常用来定制请求的参数：

| 参数              | 类型  | 说明                                                 |
| --------------- | --- | -------------------------------------------------- |
| `source`        | 字符串 | 必填。抓取引擎（例如， `universal`, `amazon`, `Google 搜索` 等）。 |
| `url` / `query` | 字符串 | 目标链接，或专用目标使用的关键词/ID。                               |
| `parse`         | 布尔值 | 设置为 `true` 可在受支持的域名上返回结构化 JSON 结果。                 |
| `render`        | 字符串 | 设置为 `html` 以启用无头浏览器来处理 JavaScript 较多的网站。           |
| `geo_location`  | 字符串 | 对结果进行本地化（例如， `美国` 或 `90210`).                      |

### 常见响应代码

| 代码    | 状态     | 说明                       |
| ----- | ------ | ------------------------ |
| `200` | `OK`   | 成功。你的数据位于 `results` 对象中。 |
| `401` | `未授权`  | 请检查控制面板中的 API 用户凭证。      |
| `429` | `请求过多` | 你已超出并发限制。                |

你可以在 [完整响应代码列表](/products/web-scraper-api/response-codes.md) 网页爬虫API产品部分中找到。

### 后续步骤

现在你已经发送了第一个查询，可以根据需求继续探索我们的其他文档：

* **在找特定域名？** 前往 [API 目标](https://developers.oxylabs.io/api-targets/) 部分，查看关于 Amazon、Google、eBay 等众多热门网站的专用指南。
* **需要高级功能？** 访问 [产品](/products/web-scraper-api.md) 专区，了解自定义解析、任务管家、云存储交付等更多功能。
* **用 AI 扩展？** 查看 [适用于 AI 工作流的解决方案](/products/web-scraper-api/solutions-for-ai-workflows.md) 或了解 [OxyCopilot](/products/web-scraper-api/web-scraper-api-playground/oxycopilot.md) 如何使用自然英语自动化你的解析逻辑。
* **不同的集成方式？** 我们的示例使用同步 Realtime 集成。你可以在 [集成方法](/integrations/web-scraper-api-integrations.md) 页面找到 Proxy Endpoint 或异步 Push-Pull 集成。


---

# Agent Instructions: 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:

```
GET https://developers.oxylabs.io/documentation/cn/kai-shi-shi-yong/kuai-su-ru-men-wang-ye-pa-chong-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
