MCPcopy Create free account
hub / github.com/apify/crawlee-python / __init__

Method __init__

src/crawlee/crawlers/_basic/_basic_crawler.py:278–510  ·  view source on GitHub ↗

Initialize a new instance. Args: configuration: The `Configuration` instance. Some of its properties are used as defaults for the crawler. event_manager: The event manager for managing events for the crawler and all its components. storage_client: The sto

(
        self,
        *,
        configuration: Configuration | None = None,
        event_manager: EventManager | None = None,
        storage_client: StorageClient | None = None,
        request_manager: RequestManager | None = None,
        session_pool: SessionPool | None = None,
        proxy_configuration: ProxyConfiguration | None = None,
        http_client: HttpClient | None = None,
        request_handler: Callable[[TCrawlingContext], Awaitable[None]] | None = None,
        max_request_retries: int = 3,
        max_requests_per_crawl: int | None = None,
        max_session_rotations: int = 10,
        max_crawl_depth: int | None = None,
        use_session_pool: bool = True,
        retry_on_blocked: bool = True,
        additional_http_error_status_codes: Iterable[int] | None = None,
        ignore_http_error_status_codes: Iterable[int] | None = None,
        concurrency_settings: ConcurrencySettings | None = None,
        request_handler_timeout: timedelta = timedelta(minutes=1),
        statistics: Statistics[TStatisticsState] | None = None,
        abort_on_error: bool = False,
        keep_alive: bool = False,
        configure_logging: bool = True,
        statistics_log_format: Literal['table', 'inline'] = 'table',
        respect_robots_txt_file: bool = False,
        status_message_logging_interval: timedelta = timedelta(seconds=10),
        status_message_callback: Callable[[StatisticsState, StatisticsState | None, str], Awaitable[str | None]]
        | None = None,
        id: int | None = None,
        _context_pipeline: ContextPipeline[TCrawlingContext] | None = None,
        _additional_context_managers: Sequence[AbstractAsyncContextManager] | None = None,
        _logger: logging.Logger | None = None,
    )

Source from the content-addressed store, hash-verified

276 __next_id = 0
277
278 def __init__(
279 self,
280 *,
281 configuration: Configuration | None = None,
282 event_manager: EventManager | None = None,
283 storage_client: StorageClient | None = None,
284 request_manager: RequestManager | None = None,
285 session_pool: SessionPool | None = None,
286 proxy_configuration: ProxyConfiguration | None = None,
287 http_client: HttpClient | None = None,
288 request_handler: Callable[[TCrawlingContext], Awaitable[None]] | None = None,
289 max_request_retries: int = 3,
290 max_requests_per_crawl: int | None = None,
291 max_session_rotations: int = 10,
292 max_crawl_depth: int | None = None,
293 use_session_pool: bool = True,
294 retry_on_blocked: bool = True,
295 additional_http_error_status_codes: Iterable[int] | None = None,
296 ignore_http_error_status_codes: Iterable[int] | None = None,
297 concurrency_settings: ConcurrencySettings | None = None,
298 request_handler_timeout: timedelta = timedelta(minutes=1),
299 statistics: Statistics[TStatisticsState] | None = None,
300 abort_on_error: bool = False,
301 keep_alive: bool = False,
302 configure_logging: bool = True,
303 statistics_log_format: Literal['table', 'inline'] = 'table',
304 respect_robots_txt_file: bool = False,
305 status_message_logging_interval: timedelta = timedelta(seconds=10),
306 status_message_callback: Callable[[StatisticsState, StatisticsState | None, str], Awaitable[str | None]]
307 | None = None,
308 id: int | None = None,
309 _context_pipeline: ContextPipeline[TCrawlingContext] | None = None,
310 _additional_context_managers: Sequence[AbstractAsyncContextManager] | None = None,
311 _logger: logging.Logger | None = None,
312 ) -> None:
313 """Initialize a new instance.
314
315 Args:
316 configuration: The `Configuration` instance. Some of its properties are used as defaults for the crawler.
317 event_manager: The event manager for managing events for the crawler and all its components.
318 storage_client: The storage client for managing storages for the crawler and all its components.
319 request_manager: Manager of requests that should be processed by the crawler.
320 session_pool: A custom `SessionPool` instance, allowing the use of non-default configuration.
321 proxy_configuration: HTTP proxy configuration used when making requests.
322 http_client: HTTP client used by `BasicCrawlingContext.send_request` method.
323 request_handler: A callable responsible for handling requests.
324 max_request_retries: Specifies the maximum number of retries allowed for a request if its processing fails.
325 This includes retries due to navigation errors or errors thrown from user-supplied functions
326 (`request_handler`, `pre_navigation_hooks` etc.).
327 This limit does not apply to retries triggered by session rotation (see `max_session_rotations`).
328 max_requests_per_crawl: Maximum number of pages to open during a crawl. The crawl stops upon reaching
329 this limit. Setting this value can help avoid infinite loops in misconfigured crawlers. `None` means
330 no limit. Due to concurrency settings, the actual number of pages visited may slightly exceed
331 this value. If used together with `keep_alive`, then the crawler will be kept alive only until
332 `max_requests_per_crawl` is achieved.
333 max_session_rotations: Maximum number of session rotations per request. The crawler rotates the session
334 if a proxy error occurs or if the website blocks the request.
335 The session rotations are not counted towards the `max_request_retries` limit.

Callers

nothing calls this directly

Calls 15

ServiceLocatorClass · 0.90
SessionPoolClass · 0.90
ImpitHttpClientClass · 0.90
configure_loggerFunction · 0.90
get_configured_log_levelFunction · 0.90
AutoscaledPoolClass · 0.90
SystemStatusClass · 0.90
RecurringTaskClass · 0.90
LoggerOnceClass · 0.90
ContextPipelineClass · 0.85
get_configurationMethod · 0.80
get_storage_clientMethod · 0.80

Tested by

no test coverage detected