Back to template gallery

Empty Python project

Empty template with basic structure for the Actor with Apify SDK that allows you to easily add your own functionality.

Language

python

Use cases

Web scraping

src/main.py

src/__main__.py

1"""
2This module defines the `main()` coroutine for the Apify Actor, executed from the `__main__.py` file.
3
4Feel free to modify this file to suit your specific needs.
5
6To build Apify Actors, utilize the Apify SDK toolkit, read more at the official documentation:
7https://docs.apify.com/sdk/python
8"""
9
10from apify import Actor
11
12
13async def main() -> None:
14    """
15    The main coroutine is being executed using `asyncio.run()`, so do not attempt to make a normal function
16    out of it, it will not work. Asynchronous execution is required for communication with Apify platform,
17    and it also enhances performance in the field of web scraping significantly.
18    """
19    async with Actor:
20        Actor.log.info('Hello from the Actor!')
21        # Write your code here

Empty Python 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

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.