Skip to content

Commit 5825dcd

Browse files
committed
Draft example of helper function to create RequestList
1 parent b6ce0d6 commit 5825dcd

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/apify/_actor.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
from datetime import timedelta
77
from typing import TYPE_CHECKING, Any, Callable, TypeVar, cast
88

9+
from crawlee.storages import RequestList
910
from lazy_object_proxy import Proxy
1011
from pydantic import AliasChoices
1112
from typing_extensions import Self
1213

1314
from apify_client import ApifyClientAsync
1415
from apify_shared.consts import ActorEnvVars, ActorExitCodes, ApifyEnvVars
1516
from apify_shared.utils import ignore_docs, maybe_extract_enum_member_value
16-
from crawlee import service_container
17+
from crawlee import service_container, Request
1718
from crawlee.events._types import Event, EventPersistStateData
1819

1920
from apify._configuration import Configuration
@@ -974,6 +975,20 @@ async def create_proxy_configuration(
974975

975976
return proxy_configuration
976977

978+
@staticmethod
979+
def create_request_list(
980+
*,
981+
actor_start_urls_input: dict
982+
) ->RequestList:
983+
return RequestList(requests=[
984+
Request.from_url(
985+
method=request_input.get("method"),
986+
url=request_input.get("url"),
987+
payload=request_input.get("payload", "").encode("utf-8"),
988+
headers=request_input.get("headers", {}),
989+
user_data=request_input.get("userData", {}),
990+
) for request_input in actor_start_urls_input])
991+
977992

978993
Actor = cast(_ActorType, Proxy(_ActorType))
979994
"""The entry point of the SDK, through which all the Actor operations should be done."""

0 commit comments

Comments
 (0)