my_actor/main.py
my_actor/__main__.py
1"""Module defines the main entry point for the Apify Actor.23Feel free to modify this file to suit your specific needs.45To build Apify Actors, utilize the Apify SDK toolkit, read more at the official documentation:6https://docs.apify.com/sdk/python7"""89from __future__ import annotations1011from apify import Actor121314asyncdefmain()->None:15"""Define a main entry point for the Apify Actor.1617 This coroutine is executed using `asyncio.run()`, so it must remain an asynchronous function for proper execution.18 Asynchronous execution is required for communication with Apify platform, and it also enhances performance in19 the field of web scraping significantly.20 """21asyncwith Actor:22 Actor.log.info('Hello from the Actor!')23# Write your code herePython empty template
Start a new web scraping project quickly and easily in Python with our empty project template. It provides a basic structure for the Actor with Apify SDK and allows you to easily add your own functionality.
Included features
- Apify SDK for Python - a toolkit for building Apify Actors and scrapers in Python
- Input schema - define and easily validate a schema for your Actor's input
- Request queue - queues into which you can put the URLs you want to scrape
- Dataset - store structured data where each object stored has the same attributes
How it works
Insert your own code to async with Actor: block. You can use the Apify SDK with any other Python library.
Resources
- Python tutorials in Academy
- Video guide on getting data using Apify API
- Integration with Make, GitHub, Zapier, Google Drive, and other apps
- A short guide on how to build web scrapers using code templates:
Related templates
Crawlee + BeautifulSoup
Crawl and scrape websites using Crawlee and BeautifulSoup. Start from a URL and store results to your Apify dataset.
OneβPage HTML Scraper with BeautifulSoup
Scrape single page with provided URL with HTTPX and extract data from page's HTML with Beautiful Soup.
BeautifulSoup
Example of a web scraper that uses Python HTTPX to scrape HTML from URLs provided on input, parses it using BeautifulSoup and saves results to storage.
Playwright + Chrome
Crawler example that uses headless Chrome driven by Playwright to scrape a website. Headless browsers render JavaScript and can help when getting blocked.
Selenium + Chrome
Scraper example built with Selenium and headless Chrome browser to scrape a website and save the results to storage. A popular alternative to Playwright.
Standby Python project
Start with a working Actor in Standby mode that stays ready in the background, then build any features you need.
Already have a solution in mind?
Sign up for a free Apify account and deploy your code to the platform in just a few minutes! If you want a head start without coding it yourself, browse our Store of existing solutions.
