1
2from apify import Actor
3
4async def main():
5 async with Actor:
6
7 actor_input = await Actor.get_input() or {}
8
9 actor_env = Actor.get_env()
10 actor_id = actor_env['actor_id']
11 actor_build_id = actor_env['actor_build_id']
12 actor_run_id = actor_env['actor_run_id']
13 actor_task_id = actor_env['actor_task_id']
14 user_id = actor_env['user_id']
15
16 client = Actor.new_client()
17 await client.actor(actor_id).get()
18 await client.build(actor_build_id).get()
19 await client.run(actor_run_id).get()
20 await client.log(actor_run_id).get()
21 if actor_task_id:
22 await client.task(actor_task_id).get()
23
24 await client.user(user_id).get()
25
26 rq = await Actor.open_request_queue()
27 await rq.add_request({'uniqueKey': 'https://apify.com', 'url': 'https://apify.com'})
28 await rq.fetch_next_request()
29 await Actor.set_value('test', {'test': 123})
30 await Actor.push_data({'abc': 456})
31 dataset = await Actor.open_dataset()
32 async for item in dataset.iterate_items():
33 pass