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 })