File tree Expand file tree Collapse file tree 1 file changed +38
-1
lines changed Expand file tree Collapse file tree 1 file changed +38
-1
lines changed Original file line number Diff line number Diff line change 56
56
@docs_name ('Actor' )
57
57
@docs_group ('Actor' )
58
58
class _ActorType :
59
- """The class of `Actor`. Only make a new instance if you're absolutely sure you need to."""
59
+ """The core class for building Actors on the Apify platform.
60
+
61
+ Actors are serverless programs running in the cloud that can perform anything from simple actions
62
+ (such as filling out a web form or sending an email) to complex operations (such as crawling an
63
+ entire website or removing duplicates from a large dataset). They are packaged as Docker containers
64
+ which accept well-defined JSON input, perform an action, and optionally produce well-defined output.
65
+
66
+ ### References
67
+
68
+ - Apify platform documentation: https://docs.apify.com/platform/actors
69
+ - Actor whitepaper: https://whitepaper.actor/
70
+
71
+ ### Usage
72
+
73
+ ```python
74
+ import asyncio
75
+
76
+ import httpx
77
+ from apify import Actor
78
+ from bs4 import BeautifulSoup
79
+
80
+
81
+ async def main() -> None:
82
+ async with Actor:
83
+ actor_input = await Actor.get_input()
84
+ async with httpx.AsyncClient() as client:
85
+ response = await client.get(actor_input['url'])
86
+ soup = BeautifulSoup(response.content, 'html.parser')
87
+ data = {
88
+ 'url': actor_input['url'],
89
+ 'title': soup.title.string if soup.title else None,
90
+ }
91
+ await Actor.push_data(data)
92
+
93
+ if __name__ == '__main__':
94
+ asyncio.run(main())
95
+ ```
96
+ """
60
97
61
98
_is_rebooting = False
62
99
_is_any_instance_initialized = False
You can’t perform that action at this time.
0 commit comments