Skip to main content

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.

from apify import Actor
from bs4 import BeautifulSoup
import requests

async def main():
async with Actor:
actor_input = await Actor.get_input()
response = requests.get(actor_input['url'])
soup = BeautifulSoup(response.content, 'html.parser')
await Actor.push_data({ 'url': actor_input['url'], 'title': soup.title.string })