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

# スクレイプを作成

> 提供された設定でURLを[スクレイプ](https://docs.olostep.com/features/scrapes)し、コンテンツを取得します。

<Tip>
  **オプションのキャッシュ:** 同じパラメーターで最近のスクレイプを再利用するために、`max_age`（秒単位）を渡してページを再取得する代わりに使用します。デフォルトは`0`（常に新しい）です。ダッシュボードのプレイグラウンドでは、デフォルトは24時間です。詳細は[キャッシング](/features/scrapes#caching)を参照してください。
</Tip>


## OpenAPI

````yaml ja/openapi/scrapes.json POST /v1/scrapes
openapi: 3.0.3
info:
  title: Scrapes API
  version: 1.0.0
servers:
  - url: https://api.olostep.com
security: []
paths:
  /v1/scrapes:
    post:
      summary: ウェブページのスクレイピングを開始する
      description: このエンドポイントでは、さまざまな設定でウェブページのスクレイピングを開始できるよ。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                url_to_scrape:
                  type: string
                  format: uri
                  description: スクレイピングを開始するURL。
                wait_before_scraping:
                  type: integer
                  description: スクレイピングを開始する前に待つ時間（ミリ秒）。
                formats:
                  type: array
                  items:
                    type: string
                    enum:
                      - html
                      - markdown
                      - text
                      - json
                      - raw_pdf
                      - screenshot
                  description: コンテンツを取得したい形式。
                remove_css_selectors:
                  type: string
                  enum:
                    - default
                    - none
                    - array
                  description: >-
                    コンテンツから特定のCSSセレクタを削除するオプション。オプションで、削除したい特定のセレクタのJSON文字列化された配列を渡すこともできる。このオプションがデフォルトに設定されている場合に削除されるCSSセレクタは
                    ['nav','footer','script','style','noscript','svg',[role=alert],[role=banner],[role=dialog],[role=alertdialog],[role=region][aria-label*=skip
                    i],[aria-modal=true] だよ。
                actions:
                  type: array
                  items:
                    type: object
                    discriminator:
                      propertyName: type
                    oneOf:
                      - type: object
                        title: 待機
                        required:
                          - type
                          - milliseconds
                        properties:
                          type:
                            type: string
                            enum:
                              - wait
                            description: 指定されたミリ秒数待機
                          milliseconds:
                            type: integer
                            minimum: 0
                            description: 待機する時間（ミリ秒単位）
                      - type: object
                        title: クリック
                        required:
                          - type
                          - selector
                        properties:
                          type:
                            type: string
                            enum:
                              - click
                            description: 要素をクリック
                          selector:
                            type: string
                            description: クリックする要素のCSSセレクタ
                      - type: object
                        title: 入力を埋める
                        required:
                          - type
                          - selector
                          - value
                        properties:
                          type:
                            type: string
                            enum:
                              - fill_input
                            description: 入力要素に値を入力する
                          selector:
                            type: string
                            description: 入力要素のCSSセレクタ
                          value:
                            type: string
                            description: 入力するテキスト
                      - type: object
                        title: スクロール
                        required:
                          - type
                          - direction
                          - amount
                        properties:
                          type:
                            type: string
                            enum:
                              - scroll
                            description: ページをスクロールする
                          direction:
                            type: string
                            enum:
                              - up
                              - down
                              - left
                              - right
                            description: スクロールする方向
                          amount:
                            type: number
                            description: ピクセル単位でスクロールする量
                  description: コンテンツを取得する前にページで実行するアクション。
                country:
                  type: string
                  description: >-
                    リクエストをロードする居住国。  サポートされている値は以下の通り： - US (アメリカ) - CA (カナダ) -
                    IT (イタリア) - IN (インド) - GB (イギリス) - JP (日本) - MX (メキシコ) - AU
                    (オーストラリア) - ID (インドネシア) - UA (UAE) - RU (ロシア) - RANDOM 
                    Google検索やGoogleニュースのスクレイピングのような一部の操作は、すべての国をサポートしているよ。
                transformer:
                  type: string
                  enum:
                    - postlight
                    - none
                  description: >-
                    使用するHTMLトランスフォーマーを指定します（ある場合）。PostlightのMercury
                    Parserライブラリを使用して、広告やその他の不要なコンテンツをスクレイピングしたコンテンツから削除します。
                remove_images:
                  type: boolean
                  description: スクレイピングされたコンテンツから画像を削除するオプション。デフォルトはfalse。
                  default: false
                remove_class_names:
                  type: array
                  items:
                    type: string
                  description: コンテンツから削除するクラス名のリスト。
                parser:
                  type: object
                  properties:
                    id:
                      type: string
                      description: 使用するパーサーのID。
                  required:
                    - id
                  description: >-
                    フォーマットとしてjsonを定義する場合、このパラメータを使用して使用するパーサーを指定できるよ。パーサーはウェブページから構造化されたコンテンツを抽出するのに役立つ。Olostepには、一般的なウェブページ用のいくつかのパーサーが組み込まれていて、自分でパーサーを作成することもできるよ。
                llm_extract:
                  type: object
                  properties:
                    schema:
                      type: object
                      description: LLM抽出のスキーマ。
                links_on_page:
                  type: object
                  properties:
                    query_to_order_links_by:
                      type: string
                      description: 提供されたクエリテキストとの類似性に基づいて返されたリンクを順序付け、最も関連性の高い一致を優先する。
                    include_links:
                      type: array
                      items:
                        type: string
                      description: >-
                        `include_links`を使用してグロブパターンで抽出されたリンクをフィルタリングする。パターンはリンクのURLパスに対して一致する。
                        "*.pdf"のようなファイル拡張子に一致させたり、"/blog/*"のような特定のパス、または
                        "https://example.com/*"のような完全なURLを使用する。ワイルドカード（*）、文字クラス（[a-z]）、交互（{pattern1,pattern2}）をサポートしているよ。注意:
                        単一の`*`は`/`を越えないので、"/blog/*"は"/blog/post-1"に一致するけど、インデックス"/blog"自体（または"/blog?tag=x"、クエリ文字列はパスの一部ではないので）には一致しない。インデックスも含めるには、"/blog*"または"{/blog,/blog/**}"を使用してね。
                    exclude_links:
                      type: array
                      items:
                        type: string
                      description: >-
                        `exclude_links`を使用してグロブパターンで抽出されたリンクをフィルタリングする。パターンはリンクのURLパスに対して一致する。
                        "*.pdf"のようなファイル拡張子に一致させたり、"/blog/*"のような特定のパス、または
                        "https://example.com/*"のような完全なURLを使用する。ワイルドカード（*）、文字クラス（[a-z]）、交互（{pattern1,pattern2}）をサポートしているよ。注意:
                        単一の`*`は`/`を越えないので、"/blog/*"は"/blog/post-1"に一致するけど、インデックス"/blog"自体（または"/blog?tag=x"、クエリ文字列はパスの一部ではないので）には一致しない。
                  description: >-
                    このオプションを使用すると、スクレイピングしたページに存在するすべてのリンクを取得できるよ。リンクは常に絶対URLとして返される。
                screen_size:
                  type: object
                  properties:
                    screen_type:
                      type: string
                      enum:
                        - default
                        - mobile
                        - desktop
                      description: >-
                        スクリーンのタイプ。デスクトップは1920x1080ピクセル、モバイルは414x896ピクセル、デフォルトは1024x768ピクセルを使用する。
                    screen_width:
                      type: integer
                      description: 'スクリーンの幅（ピクセル）。デスクトップ: 1920px、モバイル: 414px、デフォルト: 768px。'
                    screen_height:
                      type: integer
                      description: 'スクリーンの高さ（ピクセル）。デスクトップ: 1080px、モバイル: 896px、デフォルト: 1024px。'
                  description: >-
                    画面サイズの設定。プリセットの寸法は、screen_typeを通じて利用可能です：desktop
                    (1920x1080)、mobile (414x896)、またはdefault (768x1024)。
                screenshot:
                  type: object
                  properties:
                    full_page:
                      type: boolean
                      description: trueを渡すと、サイトの一番下までスクロールした後に全ページのスクリーンショットが撮られます。
                metadata:
                  type: object
                  description: ユーザー定義のメタデータ。まだサポートされていません。
                max_age:
                  type: integer
                  minimum: 0
                  default: 0
                  description: >-
                    キャッシュされたコンテンツの許容最大年齢（秒単位）。一致するスクレイプが既に存在し、max_age秒より新しい場合、Olostepは新しいブラウザスクレイプを開始する代わりに保存された結果を返します。デフォルトは0（常に新しくスクレイプ）。ダッシュボードプレイグラウンドではデフォルトは86400（24時間）。最大許容値は604800（7日間）。詳細はスクレイプ機能ドキュメントのキャッシングセクションを参照してください。
              required:
                - url_to_scrape
      responses:
        '200':
          description: スクレイプ開始の詳細を含む成功したレスポンス。
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: スクレイプID
                  object:
                    type: string
                    description: オブジェクトの種類。このエンドポイントでは「scrape」。
                  created:
                    type: number
                    description: 作成されたエポック
                  metadata:
                    type: object
                    description: ユーザー定義のメタデータ。
                  url_to_scrape:
                    type: string
                    description: スクレイプされたURL。
                  result:
                    type: object
                    properties:
                      html_content:
                        type: string
                      markdown_content:
                        type: string
                      text_content:
                        type: string
                      json_content:
                        type: string
                        description: パーサーからのコンテンツ
                      screenshot_hosted_url:
                        type: string
                      html_hosted_url:
                        type: string
                      markdown_hosted_url:
                        type: string
                      text_hosted_url:
                        type: string
                      links_on_page:
                        type: array
                        items:
                          type: string
                      page_metadata:
                        type: object
                        properties:
                          status_code:
                            type: integer
                          title:
                            type: string
                  credits_consumed:
                    type: integer
                    nullable: true
                    description: このリクエストで消費されたクレジットの数。実行完了後に設定されるよ。クレジットは請求の基準だよ。
                  cost_usd:
                    type: number
                    nullable: true
                    description: >-
                      このリクエストのUSDでの推定コスト。実行完了後に設定されるよ。消費されたクレジットとプランのレートから計算されるよ
                      — 99%の精度だけど、credits_consumedが正確な値だよ。
        '400':
          description: >-
            ターゲットURLに問題があるため、リクエストを完了できません。一般的なコード：`dns_resolution_failed`（ドメインが存在しない）、`invalid_url`（URLが不正）。
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  object:
                    type: string
                    enum:
                      - error
                  created:
                    type: integer
                  metadata:
                    type: object
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - invalid_request_error
                      code:
                        type: string
                        example: dns_resolution_failed
                      message:
                        type: string
              example:
                id: error_x2nmu5bqn6
                object: error
                created: 1777923912
                metadata: {}
                error:
                  type: invalid_request_error
                  code: dns_resolution_failed
                  message: The URL contains a typo, or the domain does not exist.
        '402':
          description: 支払いが必要 — 無効または使い果たされたAPIキー。
        '404':
          description: リクエストされたスクレイプIDが見つかりませんでした。
        '500':
          description: 内部サーバーエラー。
        '502':
          description: >-
            ターゲットウェブサイトにTLS/SSLの設定問題があります。`error.code`は常に`tls_error`で、`error.detail`は特定の低レベルSSLエラーコードを持ちます（例：`err_ssl_tlsv1_alert_internal_error`、`cert_verification_failed`）。
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  object:
                    type: string
                    enum:
                      - error
                  created:
                    type: integer
                  url:
                    type: string
                  metadata:
                    type: object
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - invalid_request_error
                      code:
                        type: string
                        enum:
                          - tls_error
                      detail:
                        type: string
                        description: 診断用の低レベルSSLエラーコード。
                      message:
                        type: string
              example:
                id: error_ogeb6rik8c
                object: error
                created: 1777923969
                url: https://example.com
                metadata: {}
                error:
                  type: invalid_request_error
                  code: tls_error
                  detail: err_ssl_tlsv1_alert_internal_error
                  message: >-
                    The website closed or rejected the TLS handshake. The server
                    may be misconfigured or use an unsupported SSL/TLS version.
        '504':
          description: >-
            スクレイプが待機時間内（約55秒）に完了しませんでした。ターゲットページが遅い、ボット保護されている、一時的に利用できない可能性があります。再試行しても安全です。
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  object:
                    type: string
                    enum:
                      - error
                  created:
                    type: integer
                  url:
                    type: string
                  metadata:
                    type: object
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - request_timeout
                      code:
                        type: string
                        enum:
                          - scrape_poll_timeout
                      message:
                        type: string
              example:
                id: error_qat3d1amjt
                object: error
                created: 1777923969
                url: https://example.com
                metadata: {}
                error:
                  type: request_timeout
                  code: scrape_poll_timeout
                  message: >-
                    Request timed out while waiting for scrape result. The page
                    may be slow, blocked for our fetchers, or temporarily
                    unavailable.
      security:
        - Authorization: []
components:
  securitySchemes:
    Authorization:
      type: http
      scheme: bearer
      description: Bearer <token>形式のBearer認証ヘッダー。<token>はあなたの認証トークンです。

````