Python API Actor
An Actor that stays running, ready to respond to HTTP requests. Good for APIs and real-time services.
my_actor/main.py
my_actor/__main__.py
1"""Module defines the main entry point for the Apify Actor.2
3Feel free to modify this file to suit your specific needs.4
5To build Apify Actors, utilize the Apify SDK toolkit, read more at the official documentation:6https://docs.apify.com/sdk/python7"""8
9from __future__ import annotations10
11from http.server import HTTPServer, SimpleHTTPRequestHandler12
13from apify import Actor14
15
16class GetHandler(SimpleHTTPRequestHandler):17 """A simple GET HTTP handler that will respond with a message."""18
19 def do_GET(self) -> None:20 """Handle GET request and respond with a message."""21 # Handle Apify standby readiness probe22 # https://docs.apify.com/platform/actors/development/programming-interface/standby#readiness-probe23 if 'x-apify-container-server-readiness-probe' in self.headers:24 self.send_response(200)25 self.end_headers()26 self.wfile.write(b'ok')27 return28
29 self.send_response(200)30 self.end_headers()31 self.wfile.write(b'Hello from Actor Standby!')32
33
34async def main() -> None:35 """Define a main entry point for the Apify Actor.36
37 This coroutine is executed using `asyncio.run()`, so it must remain an asynchronous function for proper execution.38 Asynchronous execution is required for communication with Apify platform, and it also enhances performance in39 the field of web scraping significantly.40 """41 async with Actor:42 # A simple HTTP server listening on the Actor web server port.43 with HTTPServer(('', Actor.configuration.web_server_port), GetHandler) as http_server:44 http_server.serve_forever()Start a new web scraping project quickly and easily in Python with our Standby project template. It provides a basic structure for the Actor with Apify SDK and allows you to easily add your own functionality.
Python site crawler (Crawlee + BeautifulSoup)
A crawler that follows links and gets data from static pages, with Crawlee handling retries and request queues. Uses BeautifulSoup, Python's most popular HTML parser. Can't run client-side JavaScript.
Empty Python Actor
An Actor with the Apify SDK set up, so you can build any tool you need.
Python one-page scraper (BeautifulSoup)
A scraper that gets data from one web page with BeautifulSoup. The simplest way to start scraping.
Empty Python Actor (uv)
An Actor with the Apify SDK set up and dependencies managed by the uv package manager, so you can build any tool you need.
Python site crawler (BeautifulSoup)
A lightweight crawler that follows links and gets data from static pages with BeautifulSoup. Good for blogs, news, or product listings, but it can't run client-side JavaScript.
Python browser crawler (Playwright)
A crawler that uses a real browser through Playwright, so it gets data HTTP crawlers miss. Good for social feeds, dashboards, or single-page apps.