# OnPage API 页面截图

**API:** Data API

**Endpoint:** `POST /v1/beta/dataforseo/on_page/page_screenshot`

**Tags:** DataForSEO

渲染任意 `url` 并返回截图，`full_page_screenshot` 控制是否截取整个滚动高度，`browser_screen_width` 和 `browser_screen_height` 设置视口。独立运行——无需爬取。采用 DataForSEO 的信封结构：数据位于 `tasks[0].result`，结果状态位于 `tasks[0].status_code`——被拒绝的请求仍会返回 HTTP 200。⚠️ 即使智能体还无法对图像做任何处理，图像本身也是庞大的工具结果；只有当视觉呈现才是重点时才请求截图，如果重点是文本，请使用 `post_dataforseo_on_page_content_parsing_live`。

### 计费参考

- 计量方式：按上报的响应成本计量。
- 参考请求估算：0.0051 美元。
- 参考客户倍率：1.0。不得对已结算的客户金额再次应用。

仅供参考的元数据，不是账户报价、保证价格或消费上限。资源额度不同于 Felo 额度。最终扣费以 Felo 计费记录为准。

## Base URL

- `https://openapi.felo.ai`

## Authentication

- `FeloBearerAuth` (http bearer, bearer format Felo API Key)
- `FeloApiKey` (apiKey in header `X-API-Key`)

## Request body

Required: **no**

### application/json

Schema:

```json
{
  "type": "array",
  "items": {
    "type": [
      "object",
      "null"
    ],
    "oneOf": [
      {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "<em>页面 URL</em><br><strong>必填字段</strong><br>要截取的页面的绝对 URL<br><strong>注意：</strong>如果你在此处指定的 URL 返回 404 状态码，或指定的值不是有效 URL，响应数组中将得到 <code>\"error_message\":\"Screenshot is empty\"</code>"
          },
          "accept_language": {
            "type": [
              "string",
              "null"
            ],
            "description": "<em>访问网站的语言标头</em><br>可选字段<br>支持所有语言区域格式（xx、xx-XX、xxx-XX 等）<br><strong>注意：</strong>如果你不指定此参数，某些网站可能会拒绝访问；此时，响应数组中将得到 <code>\"error_message\":\"Screenshot is empty\"</code>"
          },
          "custom_user_agent": {
            "type": [
              "string",
              "null"
            ],
            "description": "<em>自定义用户代理</em><br>可选字段<br>用于抓取网站的自定义用户代理<br>示例： <code>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36<br></code><br>默认值：<code>Mozilla/5.0 (compatible; RSiteAuditor)</code>"
          },
          "browser_preset": {
            "type": [
              "string",
              "null"
            ],
            "description": "<em>浏览器屏幕参数预设</em><br>可选字段<br>如果使用此字段，则无需指定 <code>browser_screen_width</code>、<code>browser_screen_height</code>、<code>browser_screen_scale_factor</code><p>可选值：<br><code>desktop</code>、<code>mobile</code>、<code>tablet</code><p><code>desktop</code> 预设将应用以下值：<p><code>browser_screen_width: 1920</code><br><code>browser_screen_height: 1080</code><br><code>browser_screen_scale_factor: 1</code><p><code>mobile</code> 预设将应用以下值：<p><code>browser_screen_width: 390</code><br><code>browser_screen_height: 844</code><br><code>browser_screen_scale_factor: 3</code><p><code>tablet</code> 预设将应用以下值：<p><code>browser_screen_width: 1024</code><br><code>browser_screen_height: 1366</code><br><code>browser_screen_scale_factor: 2</code><p><strong>注意：</strong>在此端点中，<code>enable_browser_rendering</code>、<code>enable_javascript</code>、<code>load_resources</code> 和 <code>enable_xhr</code> 参数始终启用。"
          },
          "browser_screen_width": {
            "type": [
              "integer",
              "null"
            ],
            "description": "<em>浏览器屏幕宽度</em><br>可选字段<br>你可以设置自定义的浏览器屏幕宽度，以便针对特定设备进行审计；<br>如果使用此字段，则无需指定 <code>browser_preset</code>，它将被忽略；<p>            最小值（像素）：<code>240</code> <br>最大值（像素）：<code>9999</code>",
            "format": "int64"
          },
          "browser_screen_height": {
            "type": [
              "integer",
              "null"
            ],
            "description": "<em>浏览器屏幕高度</em><br>可选字段<br>你可以设置自定义的浏览器屏幕高度，以便针对特定设备进行审计；<br>如果使用此字段，则无需指定 <code>browser_preset</code>，它将被忽略；<p>            最小值（像素）：<code>240</code> <br>最大值（像素）：<code>9999</code>"
          },
          "browser_screen_scale_factor": {
            "type": [
              "number",
              "null"
            ],
            "description": "<em>浏览器屏幕缩放比例</em><br>可选字段<br>你可以设置自定义的浏览器屏幕分辨率比例，以便针对特定设备进行审计；<br>如果使用此字段，则无需指定 <code>browser_preset</code>，它将被忽略；<p>            最小值：<code>0.5</code> <br>最大值：<code>3</code>"
          },
          "full_page_screenshot": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "<em>截取整页截图</em><br>可选字段<br>如果只想截取滚动前显示的页面部分，请设为 <code>false</code><br>默认值：<code>true</code>"
          },
          "disable_cookie_popup": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "<em>禁用 Cookie 弹窗 </em><br>可选字段<br>如果要禁用向用户请求 Cookie 同意的弹窗，请设为 <code>true</code>；<br>默认值：<br><code>false</code>"
          },
          "switch_pool": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "<em>切换代理池</em><br>可选字段<br>如果为 <code>true</code>，将使用其他代理池获取所请求的数据；<br>如果同时设置大量任务，导致偶尔出现 <code>rate-limit</code> 和/或 <code>site_unreachable</code> 错误，可以使用此参数"
          },
          "ip_pool_for_scan": {
            "type": [
              "string",
              "null"
            ],
            "description": "<em>代理池</em><br>可选字段<br>你可以选择用于获取所请求数据的代理池位置；<br>如果页面内容在某个位置无法访问，导致偶尔出现 <code>site_unreachable</code> 错误，可以使用此参数<br>可选值：<code>us</code>、<code>de</code>"
          }
        },
        "example": [
          {
            "url": "https://dataforseo.com/apis"
          }
        ]
      }
    ]
  },
  "example": [
    {
      "url": "https://dataforseo.com/apis"
    }
  ]
}
```

## Responses

### 200 — 操作成功

Headers:
- `X-Request-Id` (string) — 联系 Felo 支持时需提供的请求标识符。

**application/json**

Schema: object | null

```json
{
  "type": [
    "object",
    "null"
  ],
  "oneOf": [
    {
      "$ref": "#/components/schemas/Response36Afe1097B20_OnPagePageScreenshotResponseInfo"
    }
  ]
}
```

### 400 — 无法处理该请求。请检查请求参数。

### 401 — 需要有效的 Felo API 密钥。

### 402 — 由于未满足计费要求，请求无法继续。

### 403 — 该账户无权执行此操作。

### 429 — 已达到请求或支出限额。

### 502 — 服务无法完成该请求。

### 503 — API 或计费服务暂时不可用。

### 504 — 服务在处理请求时超时。

### default — 错误响应；上游透传响应可能采用提供方格式

**application/json**

Schema:

```json
{}
```

## Schema definitions

### Response36Afe1097B20_BaseResponseInfo

`#/components/schemas/Response36Afe1097B20_BaseResponseInfo`

```json
{
  "properties": {
    "version": {
      "type": [
        "string",
        "null"
      ],
      "description": "API 的当前版本"
    },
    "status_code": {
      "type": [
        "integer",
        "null"
      ],
      "description": "通用状态码\n完整响应码列表见此处"
    },
    "status_message": {
      "type": [
        "string",
        "null"
      ],
      "description": "通用信息性消息\n完整的一般信息性消息列表见此处"
    },
    "time": {
      "type": [
        "string",
        "null"
      ],
      "description": "总执行时间，秒"
    },
    "cost": {
      "type": [
        "number",
        "null"
      ],
      "description": "任务总费用，美元",
      "format": "double"
    },
    "tasks_count": {
      "type": [
        "integer",
        "null"
      ],
      "description": "tasks 数组中的任务数",
      "format": "int64"
    },
    "tasks_error": {
      "type": [
        "integer",
        "null"
      ],
      "description": "tasks 数组中返回错误的任务数",
      "format": "int64"
    }
  }
}
```

### Response36Afe1097B20_BaseResponseTaskInfo

`#/components/schemas/Response36Afe1097B20_BaseResponseTaskInfo`

```json
{
  "properties": {
    "id": {
      "type": [
        "string",
        "null"
      ],
      "description": "任务标识符\n我们系统中 UUID 格式的唯一任务标识符"
    },
    "status_code": {
      "type": [
        "integer",
        "null"
      ],
      "description": "任务的状态码\n由 DataForSEO 生成，范围如下：10000-60000\n完整响应码列表见此处"
    },
    "status_message": {
      "type": [
        "string",
        "null"
      ],
      "description": "任务的信息性消息\n完整的一般信息性消息列表见此处"
    },
    "time": {
      "type": [
        "string",
        "null"
      ],
      "description": "执行时间，秒"
    },
    "cost": {
      "type": [
        "number",
        "null"
      ],
      "description": "任务总费用，美元",
      "format": "double"
    },
    "result_count": {
      "type": [
        "integer",
        "null"
      ],
      "description": "result 数组中的元素数",
      "format": "int64"
    },
    "path": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": [
          "string",
          "null"
        ]
      },
      "description": "URL 路径"
    },
    "data": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": [
          "object",
          "null"
        ]
      },
      "description": "包含你在 POST 请求中指定的相同参数"
    }
  }
}
```

### Response36Afe1097B20_OnPagePageScreenshotResponseInfo

`#/components/schemas/Response36Afe1097B20_OnPagePageScreenshotResponseInfo`

```json
{
  "type": "object",
  "allOf": [
    {
      "$ref": "#/components/schemas/Response36Afe1097B20_BaseResponseInfo"
    },
    {
      "type": "object",
      "properties": {
        "tasks": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": [
              "object",
              "null"
            ],
            "oneOf": [
              {
                "$ref": "#/components/schemas/Response36Afe1097B20_OnPagePageScreenshotTaskInfo"
              }
            ]
          },
          "description": "<em>任务数组</em>"
        }
      }
    }
  ]
}
```

### Response36Afe1097B20_OnPagePageScreenshotResultInfo

`#/components/schemas/Response36Afe1097B20_OnPagePageScreenshotResultInfo`

```json
{
  "type": "object",
  "properties": {
    "crawl_progress": {
      "type": [
        "string",
        "null"
      ],
      "description": "<em>抓取会话的状态</em><br>可能的值：<code>in_progress</code>、<code>finished</code>"
    },
    "error_message": {
      "type": [
        "string",
        "null"
      ],
      "description": "<em>错误信息</em><br>如果指定的 <code>url</code> 返回 404 状态码或不是有效 URL，将得到 <code>\"error_message\":\"Screenshot is empty\"</code><br>如果未遇到错误，该值将为 <code>null</code>"
    },
    "items_count": {
      "type": [
        "integer",
        "null"
      ],
      "description": "<em>结果数组中的条目数</em>",
      "format": "int64"
    },
    "items": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": [
          "object",
          "null"
        ],
        "oneOf": [
          {
            "$ref": "#/components/schemas/Response36Afe1097B20_ScreenshotItem"
          }
        ]
      },
      "description": "<em>条目数组</em>"
    }
  }
}
```

### Response36Afe1097B20_OnPagePageScreenshotTaskInfo

`#/components/schemas/Response36Afe1097B20_OnPagePageScreenshotTaskInfo`

```json
{
  "type": "object",
  "allOf": [
    {
      "$ref": "#/components/schemas/Response36Afe1097B20_BaseResponseTaskInfo"
    },
    {
      "type": "object",
      "properties": {
        "result": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": [
              "object",
              "null"
            ],
            "oneOf": [
              {
                "$ref": "#/components/schemas/Response36Afe1097B20_OnPagePageScreenshotResultInfo"
              }
            ]
          },
          "description": "<em>结果数组</em>"
        }
      }
    }
  ]
}
```

### Response36Afe1097B20_ScreenshotItem

`#/components/schemas/Response36Afe1097B20_ScreenshotItem`

```json
{
  "type": "object",
  "properties": {
    "image": {
      "type": [
        "string",
        "null"
      ],
      "description": "<em>所请求页面的截图</em><br>页面截图在 DataForSEO 存储中的 URL<br><strong>注意：保存在 DataForSEO 存储中的页面截图仅在发起请求后一天内可访问</strong>"
    }
  }
}
```
