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

# 网页读取

网页读取 API 是一个专为大模型设计的网页读取工具，可以返回更适合大模型处理的结果（包含网页标题、内容、摘要等信息）。支持多个读取引擎以及多种内容格式输出。


## OpenAPI

````yaml openapi.yaml POST /web_fetch
openapi: 3.1.0
info:
  title: 极客智坊 API文档
  description: 极客智坊 API 消息接口规范文档
  version: 1.0.0
servers:
  - url: https://geekai.co/api/v1
    description: 国内代理入口
  - url: https://geekai.dev/api/v1
    description: 海外代理入口
security:
  - bearerAuth: []
  - apiKeyAuth: []
paths:
  /web_fetch:
    post:
      tags:
        - WebFetch
      summary: 网页读取接口
      description: 网页读取接口，返回更适合大模型处理的结果（网页标题、内容、摘要等）。
      operationId: createWebFetch
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - url
              properties:
                model:
                  type: string
                  description: 网页读取模型
                  default: jina-reader-v1
                url:
                  type: string
                  description: 网页URL
                  example: https://www.example.com
                engine:
                  type: string
                  description: 读取引擎，不同平台支持的读取引擎可能不一样，direct 表示速度优先，browser 表示质量优先
                  enum:
                    - direct
                    - browser
                  default: direct
                response_format:
                  type: string
                  description: 返回内容格式
                  default: markdown
                  enum:
                    - markdown
                    - html
                    - text
                    - screenshot
                timeout:
                  type: integer
                  description: 等待网页加载超时时间，单位为秒
                  default: 10
                budget_tokens:
                  type: integer
                  description: 预算token数
                  default: 200000
                target_selectors:
                  type: array
                  description: 仅提取指定 CSS 选择器中的内容
                  items:
                    type: string
                wait_for_selectors:
                  type: array
                  description: 等待指定 CSS 选择器加载后再进行内容提取（适合异步加载内容的网页）
                  items:
                    type: string
                remove_selectors:
                  type: array
                  description: 提取内容时排除指定 CSS 选择器对应的内容
                  items:
                    type: string
                openai_compatible:
                  type: boolean
                  description: 是否返回OpenAI兼容格式的内容，默认为false
                  default: false
                remove_images:
                  type: boolean
                  description: 是否移除网页内容中的图片，默认为false
                  default: false
                with_links:
                  type: boolean
                  description: 是否单独返回去重后的所有链接列表，默认为false
                  default: false
                with_images:
                  type: boolean
                  description: 是否单独返回去重后的图片URL列表，默认为false
                  default: false
                with_images_alt:
                  type: boolean
                  description: 是否返回内容中图片的alt文本，默认为false
                  default: false
                with_iframes:
                  type: boolean
                  description: 是否返回网页嵌入的iframe内容，默认为false
                  default: false
      responses:
        '200':
          description: 成功响应
          content:
            application/json:
              schema:
                type: object
                required:
                  - id
                  - created
                  - result
                  - usage
                properties:
                  id:
                    type: string
                    description: 请求ID
                  created:
                    type: integer
                    description: 请求创建时间戳
                    format: unix-timestamp
                  result:
                    type: object
                    description: 网页读取结果
                    properties:
                      url:
                        type: string
                        description: 网页链接
                      title:
                        type: string
                        description: 网页标题
                      content:
                        type: string
                        description: 网页内容，当response_format为screenshot时返回空字符串
                      screenshot:
                        type: string
                        description: 网页截图，仅当response_format为screenshot时返回
                      links:
                        type: object
                        description: 网页中提取的链接字典，仅在with_links=true时返回
                      images:
                        type: object
                        description: 网页中提取的图片URL字典，仅在with_images=true时返回
                      metadata:
                        type: object
                        description: 额外的元数据信息
                  usage:
                    type: object
                    required:
                      - total_tokens
                    properties:
                      completion_tokens:
                        type: integer
                        description: 输出内容消耗token数
                        example: 1024
                      total_tokens:
                        type: integer
                        description: 总消耗token数
                        example: 1024
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/StandardError'
components:
  responses:
    ValidationError:
      description: 参数验证错误
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: validation_error
              message:
                type: string
                example: 参数验证失败
              details:
                type: object
                additionalProperties:
                  type: string
                example:
                  field: 错误描述
    Unauthorized:
      description: 未授权
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: unauthorized
              message:
                type: string
                example: Invalid API key or token
    StandardError:
      description: 标准错误响应
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: 错误代码
          example: invalid_request
        message:
          type: string
          description: 错误信息描述
          example: 请求参数不合法
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: API认证token
    apiKeyAuth:
      type: apiKey
      in: header
      name: GeekAI-API-Key
      description: API密钥认证

````