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

# Scrape URL

> Render a URL in a browser and return the page content as HTML or Markdown.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/scrape
openapi: 3.0.0
info:
  version: 1.0.0
  title: Driver API
  description: API for creating Driver browser sessions and scraping pages.
  contact:
    name: Contact Us
    email: hello@driver.dev
    url: https://driver.dev
servers:
  - url: https://api.driver.dev
security: []
externalDocs:
  description: Learn more
  url: https://docs.driver.dev
paths:
  /v1/scrape:
    post:
      summary: Scrape URL
      description: >-
        Render a URL in a browser and return the page content as HTML or
        Markdown.
      operationId: scrapeUrl
      requestBody:
        required: true
        content:
          application/json:
            example:
              url: https://example.com
              output: html
              smartdoor:
                nodes:
                  - type: hosted
                    country: US
                timeout: 60000
                delay: 2500
                retryFresh: true
                retryCount: 2
                refreshWhile:
                  expression: >-
                    document.body?.innerText?.includes('ERR_CONNECTION_RESET')
                    || location.href.includes('/risk/challenge')
                  maxRefreshes: 3
                  minDelayMs: 700
                  maxDelayMs: 1300
            schema:
              type: object
              properties:
                url:
                  type: string
                  format: uri
                  description: URL to scrape.
                  example: https://example.com
                output:
                  type: string
                  enum:
                    - html
                    - md
                  description: Response format. Defaults to html.
                  example: html
                smartdoor:
                  type: object
                  description: >-
                    Browser rendering, waiting, retry, and node options for the
                    scrape.
                  properties:
                    nodes:
                      type: array
                      description: >-
                        Preferred hosted node configurations. Multiple entries
                        mean any match is acceptable.
                      items:
                        type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - hosted
                            description: Use hosted Driver infrastructure.
                            example: hosted
                          country:
                            type: string
                            minLength: 2
                            maxLength: 2
                            description: Preferred 2-letter country code.
                            example: US
                      example:
                        - type: hosted
                          country: US
                    timeout:
                      type: integer
                      minimum: 1000
                      maximum: 60000
                      description: Overall scrape timeout in milliseconds.
                      example: 60000
                    delay:
                      type: integer
                      minimum: 0
                      maximum: 30000
                      description: >-
                        Additional delay in milliseconds after the page settles
                        before capture.
                      example: 2500
                    retryFresh:
                      type: boolean
                      description: >-
                        Retry with a fresh browser context when a scrape attempt
                        should be retried.
                      example: true
                    retryCount:
                      type: integer
                      minimum: 0
                      description: Maximum number of retry attempts.
                      example: 2
                    refreshWhile:
                      type: object
                      description: >-
                        Refresh the page while an in-page JavaScript expression
                        evaluates truthy.
                      properties:
                        expression:
                          type: string
                          description: >-
                            Synchronous JavaScript expression evaluated in the
                            page. Refreshing continues while it returns truthy.
                          example: location.href.includes('/risk/challenge')
                        maxRefreshes:
                          type: integer
                          minimum: 0
                          description: Maximum number of page refreshes.
                          example: 3
                        minDelayMs:
                          type: integer
                          minimum: 0
                          description: Minimum delay before each refresh in milliseconds.
                          example: 700
                        maxDelayMs:
                          type: integer
                          minimum: 0
                          description: Maximum delay before each refresh in milliseconds.
                          example: 1300
                    waitForSelector:
                      type: string
                      description: CSS selector to wait for before capture.
                      example: .content-loaded
                    waitForSelectorValue:
                      type: string
                      description: >-
                        Text content the selector element must contain before
                        capture.
                      example: Ready
                    waitForFunction:
                      type: string
                      description: >-
                        Synchronous JavaScript expression that must evaluate
                        truthy before capture.
                      example: window.dataLoaded === true
                    challengeBudget:
                      type: integer
                      minimum: 2000
                      maximum: 30000
                      description: >-
                        How long to wait for an anti-bot challenge to resolve,
                        in milliseconds.
                      example: 10000
              required:
                - url
      responses:
        '200':
          description: >-
            Successfully scraped the URL. The response body is the scraped
            content.
          content:
            text/html:
              schema:
                type: string
              example: >-
                <html><head><title>Example
                Domain</title></head><body>...</body></html>
            text/markdown:
              schema:
                type: string
              example: |-
                # Example Domain

                This domain is for use in documentation examples.
            text/plain:
              schema:
                type: string
        '401':
          description: Missing or invalid token.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  error:
                    type: string
                required:
                  - success
                  - error
        '500':
          description: Scrape failed.
          content:
            text/plain:
              schema:
                type: string
              example: Internal Server Error
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  error:
                    type: string
      security:
        - Bearer: []
      servers:
        - url: https://qk.driver.dev
components:
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer
      description: Your Driver API key. Get one at https://app.driver.dev

````