betty.fetch package - Betty documentation

Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# betty.fetch package

## Submodules

- betty.fetch.http module
  - `HttpFetcher`
    - `HttpFetcher.__init__()`
    - `HttpFetcher.fetch()`
    - `HttpFetcher.fetch_file()`
- betty.fetch.static module
  - `StaticFetcher`
    - `StaticFetcher.__init__()`
    - `StaticFetcher.fetch()`
    - `StaticFetcher.fetch_file()`

## Module contents

Fetch content from the internet.

exception betty.fetch.FetchError

  Bases: `UserFacingError`, `RuntimeError`

  An error that occurred when fetching a URL.

class betty.fetch.FetchResponse

  Bases: `object`

  An HTTP response.

  __init__(headers: CIMultiDict[str], body: bytes, encoding: str) → None
  body: bytes
  encoding: str
  headers: CIMultiDict[str]
  property json: Any

    The body as JSON.

    This may raise an error if the response body cannot be represented as JSON or plain text.

  property text: str

    The body as plain text.

    This may raise an error if the response body cannot be represented as plain text.

class betty.fetch.Fetcher

  Bases: `ABC`

  Fetch content from the internet.

  abstract async fetch(url: str) → FetchResponse

    Fetch an HTTP resource.

  abstract async fetch_file(url: str) → Path

    Fetch a file.

    Returns:

      The path to the file on disk.