Apify SDK for Python
is a toolkit for
building Actors
Apify SDK for Python
is a toolkit for
building Actors
The Apify SDK for Python is the official library for creating Apify Actors in Python. It provides useful features like Actor lifecycle management, local storage emulation, and Actor event handling.

apify create my-python-actor
For example, the Apify SDK makes it easy to read the Actor input with the Actor.get_input()
method, and to save scraped data from your Actors to a dataset by simply using the Actor.push_data()
method.
import httpx
from bs4 import BeautifulSoup
from apify import Actor
async def main() -> None:
async with Actor:
actor_input = await Actor.get_input()
async with httpx.AsyncClient() as client:
response = await client.get(actor_input['url'])
soup = BeautifulSoup(response.content, 'html.parser')
data = {'url': actor_input['url'], 'title': soup.title.string if soup.title else None}
await Actor.push_data(data)