Skip to main content

Apify SDK for Python

Project description

Apify SDK for Python

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.

Installation

The Apify SDK for Python is available on PyPI as the apify package. For default installation, using Pip, run the following:

pip install apify

For users interested in integrating Apify with Scrapy, we provide a package extra called scrapy. To install Apify with the scrapy extra, use the following command:

pip install apify[scrapy]

Documentation

For usage instructions, check the documentation on Apify Docs.

Example

from apify import Actor
from bs4 import BeautifulSoup
from httpx import AsyncClient

async def main() -> None:
    async with Actor:
        # Read the input parameters from the Actor input
        actor_input = await Actor.get_input()
        # Fetch the HTTP response from the specified URL
        async with AsyncClient() as client:
            response = await client.get(actor_input['url'])
        # Process the HTML content
        soup = BeautifulSoup(response.content, 'html.parser')
        # Push the extracted data
        await Actor.push_data({
            'url': actor_input['url'],
            'title': soup.title.string,
        })

What are Actors?

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.

Creating Actors

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.

Guides

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.

Usage concepts

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.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apify-1.7.2b1.tar.gz (74.2 kB view details)

Uploaded Source

Built Distribution

apify-1.7.2b1-py3-none-any.whl (90.8 kB view details)

Uploaded Python 3

File details

Details for the file apify-1.7.2b1.tar.gz.

File metadata

  • Download URL: apify-1.7.2b1.tar.gz
  • Upload date:
  • Size: 74.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for apify-1.7.2b1.tar.gz
Algorithm Hash digest
SHA256 c3a723ba8f6a6d2345726dbc68f02c89eb489af0915e24a51b8471a8aa5fec2e
MD5 d4cb7c0fcecc55298e655eaf587a08aa
BLAKE2b-256 c897db327b9d628701fd0828fd6e68e5ec739770ffc44ae14767f1f801bd3d6a

See more details on using hashes here.

File details

Details for the file apify-1.7.2b1-py3-none-any.whl.

File metadata

  • Download URL: apify-1.7.2b1-py3-none-any.whl
  • Upload date:
  • Size: 90.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for apify-1.7.2b1-py3-none-any.whl
Algorithm Hash digest
SHA256 8743772693ef6ed469b461c3accf0cde7644b0b599b0a30691915a79f0cf80e4
MD5 2a0424beada3c8b713212353fa97bc31
BLAKE2b-256 971dbcef07c53f4b3a72c437ae62331514a7ee1646bff753d1908e8f78f8c5b6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page