Skip to content

Commit c4b5c20

Browse files
committed
Add Actor docstring
1 parent 7987324 commit c4b5c20

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

src/apify/_actor.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,44 @@
5656
@docs_name('Actor')
5757
@docs_group('Actor')
5858
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+
"""
6097

6198
_is_rebooting = False
6299
_is_any_instance_initialized = False

0 commit comments

Comments
 (0)