> ## Documentation Index
> Fetch the complete documentation index at: https://aisa.one/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 设置 Lighthouse 任务

> 把 Lighthouse 审计排队而不是等它跑完，返回任务 id。

把 Lighthouse 审计排队而不是等它跑完，返回任务 `id`。审计耗时超出一次工具调用的耐心时用它；用 `get_dataforseo_on_page_lighthouse_task_get_json` 取结果，用 `get_dataforseo_on_page_lighthouse_ready` 看哪些好了。响应包在信封里：数据在 `tasks[0].result`，成败在 `tasks[0].status_code`——请求被拒时 HTTP 仍是 200。 ⚠️ 最后拿到的仍是那份 245 KB 的报告，**上下文代价只是推迟了、没有消除**——要压缩就在这里传 `categories` / `audits`，不是等取结果时。

## 示例

```bash theme={null}
curl -X POST "https://api.aisa.one/apis/v1/dataforseo/on_page/lighthouse/task_post" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '[{"url": "...", "for_mobile": "...", "categories": "..."}]'
```


## OpenAPI

````yaml openapi/zh/dataforseo.json POST /dataforseo/on_page/lighthouse/task_post
openapi: 3.0.3
info:
  title: DataForSEO API
  version: 1.0.0
  description: 通过 AIsa 统一网关提供的 DataForSEO API 端点。
servers:
  - url: https://api.aisa.one/apis/v1
security:
  - BearerAuth: []
paths:
  /dataforseo/on_page/lighthouse/task_post:
    post:
      summary: 设置 Lighthouse 任务
      description: >-
        把 Lighthouse 审计排队而不是等它跑完，返回任务 `id`。审计耗时超出一次工具调用的耐心时用它；用
        `get_dataforseo_on_page_lighthouse_task_get_json` 取结果，用
        `get_dataforseo_on_page_lighthouse_ready` 看哪些好了。响应包在信封里：数据在
        `tasks[0].result`，成败在 `tasks[0].status_code`——请求被拒时 HTTP 仍是 200。 ⚠️
        最后拿到的仍是那份 245 KB 的报告，**上下文代价只是推迟了、没有消除**——要压缩就在这里传 `categories` /
        `audits`，不是等取结果时。
      operationId: post_dataforseo_on_page_lighthouse_submit
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: array
              items:
                type: object
                properties:
                  url:
                    type: string
                    description: >-
                      目标 URL 必填字段；应使用绝对 URL（包括 http:// 或
                      https://）指定目标页面；示例：https://dataforseo.com/
                  for_mobile:
                    type: boolean
                    description: >-
                      应用移动设备模拟；可选字段。如果设置为 true，Lighthouse
                      将使用移动设备和屏幕模拟，在移动环境下测试页面；如果设置为 false，将提供桌面端结果。默认值：false。
                  categories:
                    type: array
                    items:
                      type: string
                    description: >-
                      Lighthouse
                      审核类别，可选字段。每个类别均为审核项和审核组的集合，用于对相应部分进行加权和评分（参见官方定义）。如果忽略此字段，除非指定
                      audits，否则我们将返回所有类别的数据。使用此字段可获取此处指定类别的数据。可用值：seo、performance、best_practices、accessibility
                  audits:
                    type: array
                    items:
                      type: string
                    description: >-
                      Lighthouse 审核 可选字段 audits 是 Lighthouse
                      针对每项特定功能/优化/指标运行的独立测试，用于生成数值分数（参阅官方定义）如果忽略此字段，我们将返回所有审核的数据
                      使用此字段可获取您在此处指定的特定审核的数据 请注意，某些审核不属于特定类别，而是独立的页面质量衡量指标
                      通常有以下几种使用场景：1. 如果忽略 categories，可以使用此字段仅获取指定审核的数据，例如，如果忽略
                      "categories" 并指定 "audits":
                      ["metrics/cumulative-layout-shift","metrics/largest-contentful-paint","metrics/total-blocking-time"]，则仅会获得这些审核的数据
                      2. 如果指定某个类别，可以使用此字段额外接收不属于所指定类别的审核，例如，如果指定 "categories":
                      ["seo"] 和 "audits":
                      ["metrics/cumulative-layout-shift","metrics/largest-contentful-paint","metrics/total-blocking-time"]，则会获得
                      "performance" 下的这些审核以及 "seo" 下的所有审核 您可以在此处获取所有可用审核的完整列表
                  version:
                    type: string
                    description: >-
                      Lighthouse 版本；可选字段；通过指定版本号，您可以获取特定 Lighthouse
                      版本的结果；可用版本列表可通过 Lighthouse Versions 端点获取
                  language_name:
                    type: string
                    description: >-
                      Lighthouse 语言名称；可选字段；可通过向
                      https://api.dataforseo.com/v3/on_page/lighthouse/languages
                      单独发起请求，获取搜索引擎的可用语言及其 language_name 列表；默认值：English
                  language_code:
                    type: string
                    description: >-
                      Lighthouse 语言代码，可选字段。您可以通过向
                      https://api.dataforseo.com/v3/on_page/lighthouse/languages
                      单独发送请求，获取搜索引擎可用语言及其 language_code 的列表。默认值：en
                  tag:
                    type: string
                    description: >-
                      用户定义的任务标识符。可选字段。字符数限制为 255。您可以使用此参数标识任务并将其与结果匹配；您将在响应的
                      data 对象中找到指定的 tag 值
                  pingback_url:
                    type: string
                    description: >-
                      已完成任务的通知 URL；可选字段；任务完成后，我们会向您指定的 URL 发送 GET
                      请求以通知您；您可以使用字符串 ‘$id’ 作为 $id 变量，并使用 ‘$tag’ 作为经过 URL 编码的
                      $tag
                      变量。我们会在发送请求前设置必要的值。示例：http://your-server.com/pingscript?id=$id
                      http://your-server.com/pingscript?id=$id&tag=$tag
                      注意：pingback_url 中的特殊字符将进行 URL 编码；例如，# 字符将编码为
                      %23；请在我们的帮助中心了解更多信息
                required:
                  - url
      responses:
        '200':
          description: 成功响应
          content:
            application/json:
              schema:
                type: object
                properties:
                  version:
                    type: string
                    description: API 的当前版本
                  status_code:
                    type: integer
                    description: 通用状态码；您可以在此处查看完整的响应码列表。注意：我们强烈建议设计必要的系统来处理相关异常或错误情况
                  status_message:
                    type: string
                    description: 常规信息消息；可在此处查看常规信息消息的完整列表
                  time:
                    type: string
                    description: 执行时间（秒）
                  cost:
                    type: number
                    description: 任务总成本（美元）
                  tasks_count:
                    type: integer
                    description: tasks 数组中的任务数量
                  tasks_error:
                    type: integer
                    description: 返回错误的 tasks 数组中的任务数量
                  tasks:
                    type: array
                    items:
                      type: string
                    description: 任务数组
                  tasks.id:
                    type: string
                    description: 任务标识符，系统中采用 UUID 格式的唯一任务标识符
                  tasks.status_code:
                    type: integer
                    description: DataForSEO 生成的任务状态码；范围为：10000-60000；完整响应代码列表可在此处查看
                  tasks.status_message:
                    type: string
                    description: 任务的信息性消息，你可以在此处查看通用信息性消息的完整列表
                  tasks.time:
                    type: string
                    description: 执行时间（秒）
                  tasks.cost:
                    type: number
                    description: 任务成本（美元）
                  tasks.result_count:
                    type: integer
                    description: 结果数组中的元素数量
                  tasks.path:
                    type: array
                    items:
                      type: string
                    description: URL 路径
                  tasks.data:
                    type: object
                    description: 包含您在 POST 请求中指定的相同参数
                  tasks.result:
                    type: array
                    items:
                      type: string
                    description: 结果数组；在此情况下，该值将为 null
        '400':
          description: 错误请求
        '401':
          description: 未授权
        '429':
          description: 超出速率限制
        '500':
          description: 内部服务器错误
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.