The Apify SDK for Python is the official library to create Apify Actors in Python. It provides useful features like actor lifecycle management, local storage emulation, and actor event handling.
If you just need to access the Apify API from your Python applications, check out the Apify Client for Python instead.
For usage instructions, check the documentation on Apify Docs.
from apify import Actor
from bs4 import BeautifulSoup
import requests
async def main():
async with Actor:
response = requests.get('https://apify.com')
soup = BeautifulSoup(response.content, 'html.parser')
await Actor.push_data({ 'url': url, 'title': soup.title.string })
Actors are serverless cloud programs that can do almost anything a human can do in a web browser. They can do anything from small tasks such as filling in forms or unsubscribing from online services, all the way up to scraping and processing vast numbers of web pages.
They can be run either locally, or on the Apify platform, where you can run them at scale, monitor them, schedule them, or publish and monetize them.
If you're new to Apify, learn what is Apify in the Apify platform documentation.
To create and run Actors through Apify Console, see the Console documentation.
To create and run Python Actors locally, check the documentation for how to create and run Python Actors locally.
To see how you can use the Apify SDK with other popular libraries used for web scraping, check out our guides for using Requests and HTTPX, Beautiful Soup, Playwright, Selenium, or Scrapy.
To learn more about the features of the Apify SDK and how to use them, check out the Usage Concepts section in the sidebar, particularly the guides for the Actor lifecycle, working with storages, handling Actor events or how to use proxies.