Skip to main content
Version: 2.7

apify-sdk-python

Index

Properties

Actor

Actor:

{"content": ["The entry point of the SDK, through which all the Actor operations should be done."]}

Methods

apply_apify_settings

  • apply_apify_settings(*, settings, proxy_config): Settings
  • {"content": ["Integrates Apify configuration into a Scrapy project settings.\n\nNote: The function directly modifies the passed settings object and also returns it.\n", {"


    Parameters

    • keyword-onlysettings: Settings | None = None
    • keyword-onlyproxy_config: dict | None = None

    Returns Settings

docs_group

  • docs_group(group_name): Callable
  • {"content": ["Mark a symbol for rendering and grouping in documentation.\n\nThis decorator is used solely for documentation purposes and does not modify the behavior\nof the decorated callable.\n", {"


    Parameters

    • group_name: GroupName

    Returns Callable

docs_name

  • docs_name(symbol_name): Callable
  • {"content": ["Rename a symbol for documentation rendering.\n\nThis decorator modifies only the displayed name of the symbol in the generated documentation\nand does not affect its runtime behavior.\n", {"


    Parameters

    • symbol_name: str

    Returns Callable

encode_base62

  • encode_base62(num): str
  • {"content": ["Encode the given number to base62."]}


    Parameters

    • num: int

    Returns str

from_gzip

  • from_gzip(gzip_bytes): dict
  • {"content": ["Load a dictionary from a gzip-compressed byte stream."]}


    Parameters

    • gzip_bytes: bytes

    Returns dict

get_basic_auth_header

  • get_basic_auth_header(username, password, auth_encoding): bytes
  • {"content": ["Generate a basic authentication header for the given username and password."]}


    Parameters

    • username: str
    • password: str
    • auth_encoding: str = 'latin-1'

    Returns bytes

get_kvs_name

  • get_kvs_name(spider_name, max_length): str
  • {"content": ["Get the key value store name for a spider.\n\nThe key value store name is derived from the spider name by replacing all special characters\nwith hyphens and trimming leading and trailing hyphens. The resulting name is prefixed with\n'httpcache-' and truncated to the maximum length.\n\nThe documentation\nabout storages\nmentions that names can be up to 63 characters long, so the default max length is set to 60.\n\nSuch naming isn't unique per spider, but should be sufficiently unique for most use cases.\nThe name of the key value store should indicate to which spider it belongs, e.g. in\nthe listing in the Apify's console.\n", {"


    Parameters

    • spider_name: str
    • max_length: int = 60

    Returns str

    [{"param"

initialize_logging

  • initialize_logging(): None
  • {"content": ["Configure logging for Apify Actors and adjust Scrapy's logging settings."]}


    Returns None

read_gzip_time

  • read_gzip_time(gzip_bytes): int
  • {"content": ["Read the modification time from a gzip-compressed byte stream without decompressing the data."]}


    Parameters

    • gzip_bytes: bytes

    Returns int

run_scrapy_actor

  • run_scrapy_actor(coro): None
  • {"content": ["Start Twisted's reactor and execute the provided Actor coroutine.\n\nThis function initiates the Twisted reactor and runs the given asyncio coroutine (typically the\nActor's main) by converting it to a Deferred. This bridges the asyncio and Twisted event loops,\nenabling the Apify and Scrapy integration to work together."]}


    Parameters

    • coro: Coroutine

    Returns None

to_apify_request

  • to_apify_request(scrapy_request, spider): ApifyRequest | None
  • {"content": ["Convert a Scrapy request to an Apify request.\n", {"


    Parameters

    • scrapy_request: ScrapyRequest
    • spider: Spider

    Returns ApifyRequest | None

to_gzip

  • to_gzip(data, mtime): bytes
  • {"content": ["Dump a dictionary to a gzip-compressed byte stream."]}


    Parameters

    • data: dict
    • mtime: int | None = None

    Returns bytes

to_scrapy_request

  • to_scrapy_request(apify_request, spider): ScrapyRequest
  • {"content": ["Convert an Apify request to a Scrapy request.\n", {"


    Parameters

    • apify_request: ApifyRequest
    • spider: Spider

    Returns ScrapyRequest