Skip to main content

Router

crawlee.router.Router

Dispatches requests to registered handlers based on their labels.

Index

Constructors

__init__

  • __init__(): None
  • Returns None

Methods

__call__

  • async __call__(context): None
  • Invoke a request handler that matches the request label (or the default).


    Parameters

    • context: TCrawlingContext

    Returns None

default_handler

  • default_handler(handler): RequestHandler[TCrawlingContext]
  • A decorator used to register a default handler.

    The default handler is invoked for requests that have either no label or a label for which we have no matching handler.


    Parameters

    • handler: RequestHandler[TCrawlingContext]

    Returns RequestHandler[TCrawlingContext]

handler

  • handler(label): Callable[[RequestHandler[TCrawlingContext]], None]
  • A decorator used to register a label-based handler.

    The registered will be invoked only for requests with the exact same label.


    Parameters

    • label: str

    Returns Callable[[RequestHandler[TCrawlingContext]], None]