> ## Documentation Index
> Fetch the complete documentation index at: https://student-213fb9fc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Scrape

<div id="browser-actions">
  ## 浏览器 actions
</div>

你可以在抓取之前使用 `actions` 参数执行浏览器交互操作。这使你可以：

* 等待元素加载
* 点击按钮或链接
* 填写表单字段
* 按下按键
* 滚动页面
* 截取页面截图
* 执行自定义 JavaScript
* 生成 PDF

支持的 actions 包括 `wait`、`click`、`write`、`press`、`scroll`、`screenshot`、`scrape`、`executeJavascript` 和 `pdf`。有关包含示例的详细文档，请参阅 [高级抓取指南](https://docs.firecrawl.dev/advanced-scraping-guide#actions-actions)。


## OpenAPI

````yaml zh/api-reference/v2-openapi.json post /scrape
openapi: 3.0.0
info:
  title: Firecrawl API
  version: v2
  description: 用于与 Firecrawl 服务交互，执行网页抓取和爬取任务的 API。
  contact:
    name: Firecrawl Support
    url: https://firecrawl.dev/support
    email: support@firecrawl.dev
servers:
  - url: https://api.firecrawl.dev/v2
security:
  - bearerAuth: []
paths:
  /scrape:
    post:
      tags:
        - Scraping
      summary: 抓取单个 URL，并可选用 LLM 提取信息
      operationId: scrapeAndExtractFromUrl
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - type: object
                  properties:
                    url:
                      type: string
                      format: uri
                      description: 要爬取的 URL
                  required:
                    - url
                - $ref: '#/components/schemas/ScrapeOptions'
                - type: object
                  properties:
                    zeroDataRetention:
                      type: boolean
                      default: false
                      description: 如果为 true，则本次抓取将不保留任何数据。要启用此功能，请联系 help@firecrawl.dev
      responses:
        '200':
          description: 成功响应
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScrapeResponse'
        '402':
          description: 需要付费
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Payment required to access this resource.
        '429':
          description: 请求过多
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: >-
                      Request rate limit exceeded. Please wait and try again
                      later.
        '500':
          description: 服务器错误
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  code:
                    type: string
                    example: UNKNOWN_ERROR
                  error:
                    type: string
                    example: An unexpected error occurred on the server.
      security:
        - bearerAuth: []
components:
  schemas:
    ScrapeOptions:
      type: object
      properties:
        formats:
          $ref: '#/components/schemas/Formats'
        onlyMainContent:
          type: boolean
          description: 仅返回页面的主要内容，不包含 header、nav、footer 等元素。
          default: true
        includeTags:
          type: array
          items:
            type: string
          description: 在输出中要包含的标签。
        excludeTags:
          type: array
          items:
            type: string
          description: 在输出中需要排除的标签。
        maxAge:
          type: integer
          description: >-
            如果页面的缓存版本的生成时间距今少于该毫秒数，则返回该缓存页面；如果缓存版本距今超过该时间，则会重新抓取页面。若你不需要特别新的数据，启用此选项可将抓取速度提升至
            5 倍。默认值为 2 天。
          default: 172800000
        headers:
          type: object
          description: 随请求发送的请求头。可用于传递 cookies、User-Agent 等信息。
        waitFor:
          type: integer
          description: 指定在抓取内容前的延迟时间（毫秒），以便页面有足够时间完成加载。该等待时间是在 Firecrawl 的智能等待功能基础上的额外等待。
          default: 0
        mobile:
          type: boolean
          description: 若要模拟在移动设备上进行抓取，请将其设置为 true。适用于测试响应式页面并获取移动端截图。
          default: false
        skipTlsVerification:
          type: boolean
          description: 在发起请求时跳过 TLS 证书验证。
          default: true
        timeout:
          type: integer
          description: 请求超时时间（毫秒）。默认 30000（30 秒），最大 300000（300 秒）。
          default: 30000
          maximum: 300000
        parsers:
          type: array
          description: >-
            用于控制在抓取过程中如何处理文件。包含 "pdf" 时（默认），会提取 PDF 内容并转换为 Markdown 格式，计费基于页数（每页
            1 点数）。当传入空数组时，会以 base64 编码返回整个 PDF 文件，并对整份 PDF 按单一费率收取 1 点数。
          items:
            oneOf:
              - type: object
                properties:
                  type:
                    type: string
                    enum:
                      - pdf
                  mode:
                    type: string
                    enum:
                      - fast
                      - auto
                      - ocr
                    default: auto
                    description: >-
                      PDF 解析模式。"fast"：仅执行基于文本的提取（提取内嵌文本，速度最快）。"auto"（默认）：优先尝试
                      fast 提取，如有需要再回退到 OCR。"ocr"：对每一页强制执行 OCR 识别。
                  maxPages:
                    type: integer
                    minimum: 1
                    maximum: 10000
                    description: 从该 PDF 中最多解析的页数。必须为不超过 10000 的正整数。
                required:
                  - type
                additionalProperties: false
          default:
            - pdf
        actions:
          type: array
          description: 在抓取页面内容之前需要执行的页面 actions
          items:
            oneOf:
              - title: Wait
                oneOf:
                  - type: object
                    title: Wait by Duration
                    properties:
                      type:
                        type: string
                        enum:
                          - wait
                        description: 等待指定的毫秒数
                      milliseconds:
                        type: integer
                        minimum: 1
                        description: 要等待的毫秒数
                    required:
                      - type
                      - milliseconds
                    additionalProperties: false
                  - type: object
                    title: Wait for Element
                    properties:
                      type:
                        type: string
                        enum:
                          - wait
                        description: 等待特定元素出现
                      selector:
                        type: string
                        description: 用于等待的 CSS 选择器
                        example: '#my-element'
                    required:
                      - type
                      - selector
                    additionalProperties: false
              - type: object
                title: Screenshot
                properties:
                  type:
                    type: string
                    enum:
                      - screenshot
                    description: 截取屏幕截图。链接将在响应的 `actions.screenshots` 数组中返回。
                  fullPage:
                    type: boolean
                    description: 是否捕获整个页面的截图（忽略 viewport.height），还是仅截取当前视口区域。
                    default: false
                  quality:
                    type: integer
                    description: 截图质量，取值范围为 1 到 100，100 为最高质量。
                  viewport:
                    type: object
                    properties:
                      width:
                        type: integer
                        description: 以像素为单位的视口宽度
                      height:
                        type: integer
                        description: 视口高度（以像素为单位）
                    required:
                      - width
                      - height
                required:
                  - type
              - type: object
                title: Click
                properties:
                  type:
                    type: string
                    enum:
                      - click
                    description: 单击一个元素
                  selector:
                    type: string
                    description: 用于查找元素的查询选择器
                    example: '#load-more-button'
                  all:
                    type: boolean
                    description: 点击所有匹配该选择器的元素，而不仅仅是第一个。即使没有任何元素匹配该选择器，也不会抛出错误。
                    default: false
                required:
                  - type
                  - selector
              - type: object
                title: Write text
                properties:
                  type:
                    type: string
                    enum:
                      - write
                    description: >-
                      向输入框、文本区域或 contenteditable
                      元素写入文本。注意：在写入之前，你必须先使用「click」操作使该元素获得焦点。文本将以逐字符方式输入，以模拟键盘输入。
                  text:
                    type: string
                    description: 要键入的文本
                    example: Hello, world!
                required:
                  - type
                  - text
              - type: object
                title: Press a key
                description: >-
                  请在页面上按下一个按键。按键代码请参见：https://asawicki.info/nosense/doc/devices/keyboard/key_codes.html。
                properties:
                  type:
                    type: string
                    enum:
                      - press
                    description: 在页面上按下任意键
                  key:
                    type: string
                    description: 要按的键
                    example: Enter
                required:
                  - type
                  - key
              - type: object
                title: Scroll
                properties:
                  type:
                    type: string
                    enum:
                      - scroll
                    description: 滚动整个页面或某个特定元素
                  direction:
                    type: string
                    enum:
                      - up
                      - down
                    description: 滚动方向
                    default: down
                  selector:
                    type: string
                    description: 用于滚动的元素选择器
                    example: '#my-element'
                required:
                  - type
              - type: object
                title: Scrape
                properties:
                  type:
                    type: string
                    enum:
                      - scrape
                    description: 抓取当前页面内容，并返回其 URL 和 HTML。
                required:
                  - type
              - type: object
                title: Execute JavaScript
                properties:
                  type:
                    type: string
                    enum:
                      - executeJavascript
                    description: 在页面上执行 JavaScript 代码
                  script:
                    type: string
                    description: 待执行的 JavaScript 代码
                    example: document.querySelector('.button').click();
                required:
                  - type
                  - script
              - type: object
                title: Generate PDF
                properties:
                  type:
                    type: string
                    enum:
                      - pdf
                    description: 生成当前页面的 PDF 文件。该 PDF 文件会通过响应中的 `actions.pdfs` 数组返回。
                  format:
                    type: string
                    enum:
                      - A0
                      - A1
                      - A2
                      - A3
                      - A4
                      - A5
                      - A6
                      - Letter
                      - Legal
                      - Tabloid
                      - Ledger
                    description: 生成的 PDF 的页面大小
                    default: Letter
                  landscape:
                    type: boolean
                    description: 是否以横向方向生成 PDF
                    default: false
                  scale:
                    type: number
                    description: 生成 PDF 的缩放比例
                    default: 1
                required:
                  - type
        location:
          type: object
          description: 请求的地理位置设置。指定后，如果有可用的代理，将使用合适的代理，并模拟相应的语言和时区设置。如果未指定，则默认为“US”。
          properties:
            country:
              type: string
              description: ISO 3166-1 alpha-2 国家/地区代码（例如：“US”、“AU”、“DE”、“JP”）
              pattern: ^[A-Z]{2}$
              default: US
            languages:
              type: array
              description: >-
                按优先级排序的请求首选语言和区域设置。默认为指定位置的语言。详情请参阅：https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language
              items:
                type: string
                example: en-US
        removeBase64Images:
          type: boolean
          description: 从输出中移除所有 Base64 编码图片，以避免内容过于冗长。图片的 alt 文本会保留在输出中，但其 URL 会被占位符替换。
          default: true
        blockAds:
          type: boolean
          description: 启用广告拦截和 Cookie 弹窗拦截功能。
          default: true
        proxy:
          type: string
          enum:
            - basic
            - enhanced
            - auto
          description: |-
            指定要使用的代理类型。

             - **basic**：用于抓取几乎没有或只有基础反爬策略的网站的代理。速度快，通常可用。
             - **enhanced**：用于抓取具有高级反爬策略的网站的增强型代理。速度较慢，但在某些站点上更可靠。每个请求最多消耗 5 点积分。
             - **auto**：当 basic 代理抓取失败时，Firecrawl 会自动重试并切换为 enhanced 代理。如果使用 enhanced 重试成功，该次抓取将收取 5 点积分；如果使用 basic 一次就成功，则只按常规定价计费。
          default: auto
        storeInCache:
          type: boolean
          description: >-
            如果为 true，该页面会存储到 Firecrawl 的索引和缓存中。如果你的抓取操作可能涉及数据保护方面的顾虑，将其设置为 false
            会很有用。使用某些与敏感抓取相关的参数（例如 actions、headers）时，会被强制将此参数设为 false。
          default: true
    ScrapeResponse:
      type: object
      properties:
        success:
          type: boolean
        data:
          type: object
          properties:
            markdown:
              type: string
            summary:
              type: string
              nullable: true
              description: 如果 `formats` 中包含 `summary`，则返回页面摘要
            html:
              type: string
              nullable: true
              description: >-
                如果 `formats` 中包含 `html`，则返回页面清洗后的 HTML 内容。会移除
                `<script>`、`<style>`、`<noscript>`、`<meta>` 和 `<head>` 标签；将相对 URL
                转换为绝对 URL；将响应式图片的 `srcset` 解析为分辨率最高的版本。遵循
                `onlyMainContent`、`includeTags` 和 `excludeTags` 过滤器。
            rawHtml:
              type: string
              nullable: true
              description: >-
                如果在 `formats` 中指定 `rawHtml`，则会返回页面的原始
                HTML（未作任何修改）。不会执行任何清理或过滤操作。
            screenshot:
              type: string
              nullable: true
              description: 如果在 `formats` 中包含 `screenshot`，则会返回页面截图。截图将在 24 小时后过期，届时将无法再下载。
            links:
              type: array
              items:
                type: string
              description: 当 `formats` 中包含 `links` 时，页面上的链接列表
            actions:
              type: object
              nullable: true
              description: '`actions` 参数中指定的 actions 的执行结果。仅当请求中提供了 `actions` 参数时才会返回。'
              properties:
                screenshots:
                  type: array
                  description: 截图 URL，顺序与提供的 screenshot actions 保持一致。
                  items:
                    type: string
                    format: url
                scrapes:
                  type: array
                  description: 按照所提供的 scrape actions 顺序抓取内容。
                  items:
                    type: object
                    properties:
                      url:
                        type: string
                      html:
                        type: string
                javascriptReturns:
                  type: array
                  description: 与所提供的 executeJavascript actions 顺序一致的 JavaScript 返回值。
                  items:
                    type: object
                    properties:
                      type:
                        type: string
                      value: {}
                pdfs:
                  type: array
                  description: 按提供的 pdf actions 的顺序生成的 PDF。
                  items:
                    type: string
            metadata:
              type: object
              properties:
                title:
                  oneOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                  description: 从页面提取的标题，可以是一个字符串或字符串数组
                description:
                  oneOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                  description: 从页面提取的描述，可以是字符串或字符串数组。
                language:
                  oneOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                  nullable: true
                  description: 从页面提取的语言，可以是字符串或字符串数组
                sourceURL:
                  type: string
                  format: uri
                  description: 发起请求时使用的原始 URL。如果发生重定向，可能与最终页面的 URL 不一致。
                url:
                  type: string
                  format: uri
                  description: 跟随所有重定向后得到的最终页面 URL。
                keywords:
                  oneOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                  description: 从页面中提取的关键词，可以是字符串或字符串数组
                ogLocaleAlternate:
                  type: array
                  items:
                    type: string
                  description: 页面的其他可用语言版本
                '<any other metadata> ':
                  oneOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                  description: 从 HTML 提取的其他元数据，可以是字符串或字符串数组
                statusCode:
                  type: integer
                  description: 页面状态码
                error:
                  type: string
                  nullable: true
                  description: 页面错误信息
            warning:
              type: string
              nullable: true
              description: 在使用 LLM Extraction 时会显示。警告信息会提示你提取过程中的任何问题。
            changeTracking:
              type: object
              nullable: true
              description: >-
                当 `formats` 中包含 `changeTracking` 时的变更追踪信息。仅在请求 `changeTracking`
                格式时才会返回。
              properties:
                previousScrapeAt:
                  type: string
                  format: date-time
                  nullable: true
                  description: 当前页面用于对比的上一次抓取时间戳。如果不存在之前的抓取，则为 null。
                changeStatus:
                  type: string
                  enum:
                    - new
                    - same
                    - changed
                    - removed
                  description: >-
                    两个页面版本之间的比较结果。`new` 表示该页面之前不存在，`same` 表示内容没有变化，`changed`
                    表示内容已发生变化，`removed` 表示该页面已被移除。
                visibility:
                  type: string
                  enum:
                    - visible
                    - hidden
                  description: >-
                    当前页面/URL 的可见性。`visible` 表示该 URL 是通过自然途径（链接或站点地图）发现的，`hidden`
                    表示该 URL 是通过之前抓取的历史记录（“记忆”）发现的。
                diff:
                  type: string
                  nullable: true
                  description: 在使用“git-diff”模式时的 Git 风格变更 diff。仅在模式设置为“git-diff”时返回。
                json:
                  type: object
                  nullable: true
                  description: >-
                    使用 `json` 模式时的 JSON 比较结果。仅在模式设置为 `json` 时返回。该字段会根据 `schema`
                    中定义的类型，输出一个列表，包含 `previous` 和 `current` 抓取结果中的所有键及其对应的值。示例见
                    [此处](/features/change-tracking)
            branding:
              type: object
              nullable: true
              description: 如果在 `formats` 中包含 `branding`，则会从页面中提取品牌相关信息，包括颜色、字体、版式、间距、组件等。
              properties:
                colorScheme:
                  type: string
                  enum:
                    - light
                    - dark
                  description: 页面检测到的配色方案。
                logo:
                  type: string
                  nullable: true
                  description: 主徽标的 URL。
                colors:
                  type: object
                  nullable: true
                  description: 从页面中提取的品牌颜色。
                  properties:
                    primary:
                      type: string
                      description: 主品牌颜色（十六进制颜色值）。
                    secondary:
                      type: string
                      description: 次要品牌颜色（十六进制颜色值）。
                    accent:
                      type: string
                      description: 强调色（十六进制颜色值）。
                    background:
                      type: string
                      description: 背景颜色（十六进制颜色值）。
                    textPrimary:
                      type: string
                      description: 主文本颜色（十六进制颜色值）。
                    textSecondary:
                      type: string
                      description: 次要文本颜色（十六进制颜色值）。
                    link:
                      type: string
                      description: 链接颜色（十六进制颜色值）。
                    success:
                      type: string
                      description: 成功 / 正向状态颜色（十六进制）。
                    warning:
                      type: string
                      description: 警告状态颜色（十六进制）。
                    error:
                      type: string
                      description: 错误 / 危险状态颜色（十六进制）。
                fonts:
                  type: array
                  nullable: true
                  description: 页面中使用的字体族数组。
                  items:
                    type: object
                    properties:
                      family:
                        type: string
                        description: 字体族名称。
                typography:
                  type: object
                  nullable: true
                  description: 详细的排版配置。
                  properties:
                    fontFamilies:
                      type: object
                      description: 按角色划分的字体族配置。
                      properties:
                        primary:
                          type: string
                          description: 主字体族。
                        heading:
                          type: string
                          description: 标题字体族。
                        code:
                          type: string
                          description: 代码 / 等宽字体族。
                    fontSizes:
                      type: object
                      description: 各文本层级的字体大小。
                      properties:
                        h1:
                          type: string
                        h2:
                          type: string
                        h3:
                          type: string
                        body:
                          type: string
                    fontWeights:
                      type: object
                      description: 字重（font weight）规范。
                      properties:
                        light:
                          type: integer
                        regular:
                          type: integer
                        medium:
                          type: integer
                        bold:
                          type: integer
                    lineHeights:
                      type: object
                      description: 各类文本的行高（line-height）。
                      properties:
                        heading:
                          type: string
                        body:
                          type: string
                spacing:
                  type: object
                  nullable: true
                  description: 间距与布局相关信息。
                  properties:
                    baseUnit:
                      type: integer
                      description: 基准间距（像素）。
                    borderRadius:
                      type: string
                      description: 默认圆角半径。
                    padding:
                      type: object
                      description: 内边距（padding）规格。
                    margins:
                      type: object
                      description: 外边距（margin）规格。
                components:
                  type: object
                  nullable: true
                  description: UI 组件样式规范。
                  properties:
                    buttonPrimary:
                      type: object
                      description: 主按钮样式规范。
                      properties:
                        background:
                          type: string
                        textColor:
                          type: string
                        borderRadius:
                          type: string
                    buttonSecondary:
                      type: object
                      description: 次级按钮样式配置。
                      properties:
                        background:
                          type: string
                        textColor:
                          type: string
                        borderColor:
                          type: string
                        borderRadius:
                          type: string
                    input:
                      type: object
                      description: 输入框样式配置。
                icons:
                  type: object
                  nullable: true
                  description: 图标样式配置。
                images:
                  type: object
                  nullable: true
                  description: 品牌相关图片。
                  properties:
                    logo:
                      type: string
                      description: Logo 图片 URL。
                    favicon:
                      type: string
                      description: 网站图标（favicon）URL。
                    ogImage:
                      type: string
                      description: Open Graph 图片 URL。
                animations:
                  type: object
                  nullable: true
                  description: 动效与过渡配置。
                layout:
                  type: object
                  nullable: true
                  description: 布局配置（栅格、页眉/页脚高度）。
                personality:
                  type: object
                  nullable: true
                  description: 品牌个性特征（语气、活力、目标受众）。
    Formats:
      type: array
      items:
        oneOf:
          - type: object
            title: Markdown
            properties:
              type:
                type: string
                enum:
                  - markdown
            required:
              - type
          - type: object
            title: Summary
            properties:
              type:
                type: string
                enum:
                  - summary
            required:
              - type
          - type: object
            title: HTML
            properties:
              type:
                type: string
                enum:
                  - html
            required:
              - type
          - type: object
            title: Raw HTML
            properties:
              type:
                type: string
                enum:
                  - rawHtml
            required:
              - type
          - type: object
            title: Links
            properties:
              type:
                type: string
                enum:
                  - links
            required:
              - type
          - type: object
            title: Images
            properties:
              type:
                type: string
                enum:
                  - images
            required:
              - type
          - type: object
            title: Screenshot
            properties:
              type:
                type: string
                enum:
                  - screenshot
              fullPage:
                type: boolean
                description: 是否捕获整个页面的截图（忽略 viewport.height），还是仅截取当前视口区域。
                default: false
              quality:
                type: integer
                description: 截图质量，范围为 1 到 100，100 为最高质量。
              viewport:
                type: object
                properties:
                  width:
                    type: integer
                    description: 视口宽度（像素）
                  height:
                    type: integer
                    description: 视口高度（像素）
                required:
                  - width
                  - height
            required:
              - type
          - type: object
            title: JSON
            properties:
              type:
                type: string
                enum:
                  - json
              schema:
                type: object
                description: >-
                  用于 JSON 输出的 Schema，必须符合 [JSON
                  Schema](https://json-schema.org/) 规范。
              prompt:
                type: string
                description: 用于生成 JSON 输出的提示
            required:
              - type
          - type: object
            title: Change Tracking
            properties:
              type:
                type: string
                enum:
                  - changeTracking
              modes:
                type: array
                items:
                  type: string
                  enum:
                    - git-diff
                    - json
                description: 用于变更跟踪的模式。`git-diff` 提供详细的差异对比，而 `json` 则对比提取出的 JSON 数据。
              schema:
                type: object
                description: >-
                  在使用「json」模式进行 JSON 提取时所用的 schema。用于定义要提取和对比的数据结构。必须符合 [JSON
                  Schema](https://json-schema.org/) 标准。
              prompt:
                type: string
                description: 在使用 `json` 模式进行变更跟踪时要使用的提示词。如果未提供，将使用默认提示词。
              tag:
                type: string
                nullable: true
                default: null
                description: >-
                  用于变更跟踪的标签。标签可以将变更跟踪历史划分为不同的「分支」，带有特定标签的变更跟踪只会与同一标签下的抓取结果进行比较。如果未提供，则会使用默认标签（null）。
            required:
              - type
          - type: object
            title: Branding
            properties:
              type:
                type: string
                enum:
                  - branding
            required:
              - type
      description: >-
        要在响应中包含的输出 formats。你可以指定一个或多个
        formats，既可以使用字符串（例如：`'markdown'`），也可以使用带有其他选项的对象（例如：`{ type: 'json',
        schema: {...} }`）。某些 formats 需要配置特定选项。示例：`['markdown', { type: 'json',
        schema: {...} }]`。
      default:
        - markdown
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````