> 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-scraper-api/features/result-processing-and-storage/cloud-storage.md).

# 云存储

直接在你的 S3、GCS、OSS 或其他兼容 S3 的存储中获取抓取结果。

网页爬虫API 作业结果存储在我们的存储中。您可以通过以下方式从我们的存储获取结果： `GET`获取 `/results` 端点。

或者，我们可以将结果上传到您的云存储。这样，您无需发出额外请求来获取结果——所有内容都会直接发送到您的存储桶。

{% hint style="info" %}
云存储集成仅适用于 [**Push-Pull**](/products/cn/web-scraper-api/integration-methods/push-pull.md) 集成方法。
{% endhint %}

目前，我们支持以下云存储服务：

* [**Google Cloud Storage**](#google-cloud-storage)
* [**Amazon S3**](#amazon-s3)
* [**Alibaba Cloud 对象存储服务 (OSS)**](#alibaba-cloud-object-storage-service-oss)
* [**BytePlus Torch 对象存储 (TOS)**](#byteplus-tos)
* [**其他兼容 S3 的存储**](#other-s3-compatible-storage)

如果您希望使用其他类型的存储，请联系您的客户经理以讨论功能交付时间表。

上传路径如下： `YOUR_BUCKET_NAME/job_ID.json`。提交作业后，您将在我们返回的响应中找到作业 ID。

#### 输入

<table><thead><tr><th>参数</th><th width="187.33333333333331">说明</th><th>有效值</th></tr></thead><tbody><tr><td><code>storage_type</code></td><td>您的云存储类型。</td><td><p><code>gcs</code> (Google Cloud Storage)；</p><p><code>s3</code> (AWS S3)； <code>tos</code> (BytePlus TOS)；</p><p><code>s3_compatible</code> （任何兼容 S3 的存储）。</p></td></tr><tr><td><code>storage_url</code></td><td>您的云存储桶名称 / URL。</td><td><ul><li>任意 <code>s3</code> , <code>gcs</code> ，或 <code>tos</code> 存储桶名称；</li><li>任意 <code>兼容 S3 的</code> 存储 URL。</li></ul></td></tr></tbody></table>

## **Google Cloud Storage**

以下负载使网页爬虫API 抓取 `https://example.com` 并将结果放入 Google Cloud Storage 存储桶。

```json
{
    "source": "universal",
    "url": "https://example.com",
    "storage_type": "gcs",
    "storage_url": "bucket_name/path"
}
```

要将您的作业结果上传到 Google Cloud Storage 存储桶，请按如下所示为我们的服务设置特殊权限：

{% stepper %}
{% step %}
**创建自定义角色**

<div align="left"><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fgit-blob-32292235b253d2435d5e0a8d88558c068872956d%2Fgcs-1.png?alt=media" alt=""></div>
{% endstep %}

{% step %}
**添加 `storage.objects.create` 权限**

<div align="left"><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fgit-blob-815bad910c08ed706d3df43ddb20fff0f0563d6d%2Fgcs-2.png?alt=media" alt=""></div>
{% endstep %}

{% step %}
**将其分配给 Oxylabs**

在 **新成员** 字段中，输入以下 **Oxylabs 服务账号电子邮件地址**:

```
oxyserps-storage@oxyserps-storage.iam.gserviceaccount.com
```

<div align="left"><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fgit-blob-df5b74908cc6943c8d620b5e14487f2d003ebe43%2Fgcs-3.png?alt=media" alt=""></div>
{% endstep %}
{% endstepper %}

## **Amazon S3**

以下负载使网页爬虫API 抓取 `https://example.com` 并将结果放入 Amazon S3 存储桶。

```json
{
    "source": "universal",
    "url": "https://example.com",
    "storage_type": "s3",
    "storage_url": "bucket_name/path"
}
```

要将您的作业结果上传到 Amazon S3 存储桶，请为我们的服务设置访问权限。为此，请前往 [**https://s3.console.aws.amazon.com/**](https://s3.console.aws.amazon.com/) → **`S3`** → **`存储`** → **`存储桶名称`**` `` ``(如果您没有，请新建一个) ` → **`权限`** → **`存储桶策略`**.

<div align="left"><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fgit-blob-1c27676a6e925e4a8c257cf422e991c8a6a1af2c%2Fs3_bucket_policy.png?alt=media" alt=""></div>

您可以在下方或代码示例区域找到存储桶策略。

{% file src="/files/613dde66c560f9f6d82fc2197d93ed7699fd0ddf" %}
S3 存储桶策略
{% endfile %}

不要忘记更改以下项中的存储桶名称： `YOUR_BUCKET_NAME`。此策略允许我们写入您的存储桶、授予您对已上传文件的访问权限，并获知存储桶的位置。

```json
{
    "Version": "2012-10-17",
    "Id": "Policy1577442634787",
    "Statement": [
        {
            "Sid": "Stmt1577442633719",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::324311890426:user/oxylabs.s3.uploader"
            },
            "Action": "s3:GetBucketLocation",
            "Resource": "arn:aws:s3:::YOUR_BUCKET_NAME"
        },
        {
            "Sid": "Stmt1577442633719",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::324311890426:user/oxylabs.s3.uploader"
            },
            "Action": [
                "s3:PutObject",
                "s3:PutObjectAcl"
            ],
            "Resource": "arn:aws:s3:::YOUR_BUCKET_NAME/*"
        }
    ]
}
```

## Alibaba Cloud 对象存储服务 (OSS)

以下负载使网页爬虫API 抓取 `https://example.com` 并将结果放入 Alibaba Cloud OSS 存储桶。

```json
{
    "source": "universal",
    "url": "https://example.com",
    "storage_type": "s3_compatible",
    "storage_url": "https://ACCESS_KEY_ID:ACCESS_KEY_SECRET@BUCKET_NAME.oss-REGION.aliyuncs.com/FOLDER_NAME"
}
```

### 构建存储 URL <a href="#forming-the-storage-url" id="forming-the-storage-url"></a>

存储 URL 格式：

```http
https://ACCESS_KEY_ID:ACCESS_KEY_SECRET@BUCKET_NAME.oss-REGION.aliyuncs.com/FOLDER_NAME
```

{% hint style="warning" %}
目前， **我们无法上传到根存储桶**。请为您的上传提供具体的文件夹名称。
{% endhint %}

您可在此找到存储桶的 `BUCKET_NAME` 和 `oss-REGION` ：

<figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fgit-blob-3258197766d6326f572b9230603b3f700738db36%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### 创建 AccessKey 和密钥 <a href="#creating-the-access-key-and-secret" id="creating-the-access-key-and-secret"></a>

要通过兼容 S3 的接口使用 Alibaba OSS，您必须创建 `ACCESS_KEY_ID` 和 `ACCESS_KEY_SECRET` ，如下所示。有关更多信息，请参阅 [![](https://img.alicdn.com/tfs/TB1ugg7M9zqK1RjSZPxXXc4tVXa-32-32.png)如何使用 Amazon S3 SDK 访问 OSS](https://www.alibabacloud.com/help/en/oss/developer-reference/use-amazon-s3-sdks-to-access-oss?spm=a2c63.p38356.0.i1).

{% stepper %}
{% step %}
前往 **AccessKey 账户菜单**

<div align="left"><figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fgit-blob-7a0c00eac6fd02fed28c7be5a5522985de3625d5%2Fimage.png?alt=media" alt="" width="422"><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
登录 **RAM console**

使用 [RAM console](https://ram.console.aliyun.com/) 访问 **Alibaba Cloud 账号** 或 **RAM 用户** ，该用户拥有管理权限。
{% endstep %}

{% step %}
前往 **身份** → **用户** 位于左侧导航窗格中
{% endstep %}

{% step %}
选择 **创建用户** 并使用 **RAM User AccessKey：**

<div align="left"><figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fgit-blob-e06b15f92c10028d2f5c368321821a90abf01f3f%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fgit-blob-4103046af7ce401cd189cd53f238fddf41b64ab5%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
**向 RAM 用户授予权限**

新创建的 RAM 用户没有任何权限。您必须授予 **AliyunOSSFullAccess** 权限给 RAM 用户。然后，RAM 用户便可访问所需的 Alibaba Cloud 资源。有关更多信息，请参阅 [向 RAM 用户授予权限](https://www.alibabacloud.com/help/en/ram/user-guide/grant-permissions-to-the-ram-user#task-187800).

<div align="left"><figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fgit-blob-6d76a9af42bd9f8eaabdbee6c4baadd5824a0a09%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
获取您的 **AccessKey ID** 和 **AccessKey Secret**

授予权限后，返回 **身份验证** 部分，然后在 **Access Key** 部分中，选择 **创建 AccessKey**。选择为以下对象创建 Access Key： **第三方服务**。随后您将看到一个 `ACCESS_KEY_ID` 和 `ACCESS_KEY_SECRET`，随后您可以在请求中使用它。
{% endstep %}
{% endstepper %}

### Alibaba OSS 速率限制 <a href="#alibaba-oss-ratelimits" id="alibaba-oss-ratelimits"></a>

对 Alibaba OSS 执行并发上传时，可能会触及其账号/存储桶速率限制，上传将因以下错误开始超时：

<div align="left"><figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fgit-blob-8c6734c7968642444e43843fb1f200f0ab739c81%2Fimage.png?alt=media" alt="" width="563"><figcaption></figcaption></figure></div>

在这种情况下，请联系 Alibaba OSS 支持团队以提高您的 OSS 速率限制。

## BytePlus TOS

您可以将抓取结果直接上传到 BytePlus Torch 对象存储 (TOS) 存储桶。

要成功连接，您需要：

* 已正确配置的 TOS 存储桶。
* 您的访问密钥和密钥。
* 兼容 S3 的端点。

您可以在官方 BytePlus [文档](https://docs.byteplus.com/en/docs/tos/docs-region-and-endpoint).

### 示例

以下负载将抓取 `https://example.com` 并将结果上传到您的 TOS 存储桶。

```json
{
    "source": "universal",
    "url": "https://example.com",
    "storage_type": "tos",
    "storage_url": "https://access_key:secret_key@endpoint/bucket_name/path"
}
```

### 参数 <a href="#docs-internal-guid-dbfc45c7-7fff-9754-b71a-bacb24e2ac54" id="docs-internal-guid-dbfc45c7-7fff-9754-b71a-bacb24e2ac54"></a>

<table><thead><tr><th width="166">参数</th><th width="165">可用值</th><th>说明</th></tr></thead><tbody><tr><td><code>storage_type</code></td><td><code>tos</code></td><td>指定 BytePlus TOS 作为存储提供商。</td></tr><tr><td><code>storage_url</code></td><td>URL 字符串</td><td>指向您的 TOS 存储桶的已认证 URL（请参阅以下格式）。</td></tr></tbody></table>

### 存储 URL 格式

该 `storage_url` 必须使用您的 TOS 凭据和存储桶详细信息构建。

```bash
https://access_key:secret_key@endpoint/bucket_name/path
```

| 组件            | 说明                                             |
| ------------- | ---------------------------------------------- |
| `access_key`  | 您的 BytePlus 访问密钥 ID。                           |
| `secret_key`  | 您的 BytePlus 私有访问密钥。                            |
| `endpoint`    | 特定区域的端点（例如， `tos-cn-hongkong.bytepluses.com`). |
| `bucket_name` | 目标存储桶名称。                                       |
| `path`        | *（可选）* 存储桶的特定文件夹路径。                            |

{% hint style="warning" %}
如果您的 Access Key 或 Secret Key 包含特殊字符（例如 `/`, `+`，或 `=`），则它们 **必须进行 URL 编码** 然后再构建字符串。
{% endhint %}

### 输出文件命名

Oxylabs 会根据作业详细信息自动为上传的对象生成文件名：

* **HTML/内容：** `{query_id}_{timestamp}.html`
* **解析后的数据：** `{query_id}_results.json`

您可以在存储桶中的以下位置访问文件： `tos://{bucket_name}/{path}/{filename}`

## 其他兼容 S3 的存储

如果您希望将结果交付到兼容 S3 的存储位置，则必须包含存储桶的 `ACCESS_KEY:SECRET` 认证字符串，位于 `storage_url` 负载中的值：

```json
{
    "source": "universal",
    "url": "https://example.com",
    "storage_type": "s3_compatible",
    "storage_url": "https://ACCESS_KEY:SECRET@s3.oxylabs.io/my-videos"
}
```


---

# 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/web-scraper-api/features/result-processing-and-storage/cloud-storage.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.
