diff --git a/templates/python-beautifulsoup/requirements.txt b/templates/python-beautifulsoup/requirements.txt index 3aba82cb..a7617dd9 100644 --- a/templates/python-beautifulsoup/requirements.txt +++ b/templates/python-beautifulsoup/requirements.txt @@ -1,6 +1,7 @@ -# Add your dependencies here. -# See https://pip.pypa.io/en/latest/reference/requirements-file-format/ -# for how to format them +# Define your Python dependencies below. For formatting guidelines, refer to: +# https://pip.pypa.io/en/latest/reference/requirements-file-format/ + apify ~= 1.3.0 beautifulsoup4 ~= 4.12.2 -httpx ~= 0.25.0 +httpx ~= 0.25.2 +types-beautifulsoup4 ~= 4.12.0.7 diff --git a/templates/python-beautifulsoup/src/__init__.py b/templates/python-beautifulsoup/src/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/templates/python-beautifulsoup/src/__main__.py b/templates/python-beautifulsoup/src/__main__.py index 0b2cd323..ec715780 100644 --- a/templates/python-beautifulsoup/src/__main__.py +++ b/templates/python-beautifulsoup/src/__main__.py @@ -1,3 +1,10 @@ +""" +This module serves as the entry point for executing the Apify Actor. It handles the configuration of logging +settings. The `main()` coroutine is then executed using `asyncio.run()`. + +Feel free to modify this file to suit your specific needs. +""" + import asyncio import logging @@ -5,6 +12,7 @@ from .main import main +# Configure loggers handler = logging.StreamHandler() handler.setFormatter(ActorLogFormatter()) @@ -16,4 +24,5 @@ apify_logger.setLevel(logging.DEBUG) apify_logger.addHandler(handler) +# Execute the Actor main coroutine asyncio.run(main()) diff --git a/templates/python-beautifulsoup/src/main.py b/templates/python-beautifulsoup/src/main.py index 3aee58ab..09c39d0b 100644 --- a/templates/python-beautifulsoup/src/main.py +++ b/templates/python-beautifulsoup/src/main.py @@ -1,3 +1,12 @@ +""" +This module defines the `main()` coroutine for the Apify Actor, executed from the `__main__.py` file. + +Feel free to modify this file to suit your specific needs. + +To build Apify Actors, utilize the Apify SDK toolkit, read more at the official documentation: +https://docs.apify.com/sdk/python +""" + from urllib.parse import urljoin from bs4 import BeautifulSoup @@ -6,7 +15,12 @@ from apify import Actor -async def main(): +async def main() -> None: + """ + The main coroutine is being executed using `asyncio.run()`, so do not attempt to make a normal function + out of it, it will not work. Asynchronous execution is required for communication with Apify platform, + and it also enhances performance in the field of web scraping significantly. + """ async with Actor: # Read the Actor input actor_input = await Actor.get_input() or {} diff --git a/templates/python-empty/requirements.txt b/templates/python-empty/requirements.txt index 0d8438ab..1f0e99de 100644 --- a/templates/python-empty/requirements.txt +++ b/templates/python-empty/requirements.txt @@ -1 +1,4 @@ +# Define your Python dependencies below. For formatting guidelines, refer to: +# https://pip.pypa.io/en/latest/reference/requirements-file-format/ + apify ~= 1.3.0 diff --git a/templates/python-empty/src/__main__.py b/templates/python-empty/src/__main__.py index aa649ea7..ec715780 100644 --- a/templates/python-empty/src/__main__.py +++ b/templates/python-empty/src/__main__.py @@ -1,3 +1,10 @@ +""" +This module serves as the entry point for executing the Apify Actor. It handles the configuration of logging +settings. The `main()` coroutine is then executed using `asyncio.run()`. + +Feel free to modify this file to suit your specific needs. +""" + import asyncio import logging @@ -5,7 +12,7 @@ from .main import main -# Set up logging of messages from the Apify SDK +# Configure loggers handler = logging.StreamHandler() handler.setFormatter(ActorLogFormatter()) @@ -17,4 +24,5 @@ apify_logger.setLevel(logging.DEBUG) apify_logger.addHandler(handler) +# Execute the Actor main coroutine asyncio.run(main()) diff --git a/templates/python-empty/src/main.py b/templates/python-empty/src/main.py index b0a1fcb0..7bf47b01 100644 --- a/templates/python-empty/src/main.py +++ b/templates/python-empty/src/main.py @@ -1,8 +1,21 @@ -# Apify SDK - toolkit for building Apify Actors (Read more at https://docs.apify.com/sdk/python) +""" +This module defines the `main()` coroutine for the Apify Actor, executed from the `__main__.py` file. + +Feel free to modify this file to suit your specific needs. + +To build Apify Actors, utilize the Apify SDK toolkit, read more at the official documentation: +https://docs.apify.com/sdk/python +""" + from apify import Actor -async def main(): +async def main() -> None: + """ + The main coroutine is being executed using `asyncio.run()`, so do not attempt to make a normal function + out of it, it will not work. Asynchronous execution is required for communication with Apify platform, + and it also enhances performance in the field of web scraping significantly. + """ async with Actor: Actor.log.info('Hello from the Actor!') # Write your code here diff --git a/templates/python-playwright/requirements.txt b/templates/python-playwright/requirements.txt index 0c213424..3415f835 100644 --- a/templates/python-playwright/requirements.txt +++ b/templates/python-playwright/requirements.txt @@ -1,5 +1,5 @@ -# Add your dependencies here. -# See https://pip.pypa.io/en/latest/reference/requirements-file-format/ -# for how to format them +# Define your Python dependencies below. For formatting guidelines, refer to: +# https://pip.pypa.io/en/latest/reference/requirements-file-format/ + apify ~= 1.3.0 playwright ~= 1.39.0 diff --git a/templates/python-playwright/src/__init__.py b/templates/python-playwright/src/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/templates/python-playwright/src/__main__.py b/templates/python-playwright/src/__main__.py index 0b2cd323..ec715780 100644 --- a/templates/python-playwright/src/__main__.py +++ b/templates/python-playwright/src/__main__.py @@ -1,3 +1,10 @@ +""" +This module serves as the entry point for executing the Apify Actor. It handles the configuration of logging +settings. The `main()` coroutine is then executed using `asyncio.run()`. + +Feel free to modify this file to suit your specific needs. +""" + import asyncio import logging @@ -5,6 +12,7 @@ from .main import main +# Configure loggers handler = logging.StreamHandler() handler.setFormatter(ActorLogFormatter()) @@ -16,4 +24,5 @@ apify_logger.setLevel(logging.DEBUG) apify_logger.addHandler(handler) +# Execute the Actor main coroutine asyncio.run(main()) diff --git a/templates/python-playwright/src/main.py b/templates/python-playwright/src/main.py index e994698b..1f4f6ca5 100644 --- a/templates/python-playwright/src/main.py +++ b/templates/python-playwright/src/main.py @@ -1,3 +1,12 @@ +""" +This module defines the `main()` coroutine for the Apify Actor, executed from the `__main__.py` file. + +Feel free to modify this file to suit your specific needs. + +To build Apify Actors, utilize the Apify SDK toolkit, read more at the official documentation: +https://docs.apify.com/sdk/python +""" + from urllib.parse import urljoin from playwright.async_api import async_playwright @@ -9,7 +18,12 @@ # When running on the Apify platform, they are already included in the Actor's Docker image. -async def main(): +async def main() -> None: + """ + The main coroutine is being executed using `asyncio.run()`, so do not attempt to make a normal function + out of it, it will not work. Asynchronous execution is required for communication with Apify platform, + and it also enhances performance in the field of web scraping significantly. + """ async with Actor: # Read the Actor input actor_input = await Actor.get_input() or {} diff --git a/templates/python-scrapy/requirements.txt b/templates/python-scrapy/requirements.txt index 4706653a..168e2705 100644 --- a/templates/python-scrapy/requirements.txt +++ b/templates/python-scrapy/requirements.txt @@ -1,5 +1,5 @@ -# You can add your dependencies here. -# See https://pip.pypa.io/en/latest/reference/requirements-file-format/ for how to format them. +# Define your Python dependencies below. For formatting guidelines, refer to: +# https://pip.pypa.io/en/latest/reference/requirements-file-format/ apify[scrapy] ~= 1.3.0 nest-asyncio ~= 1.5.8 diff --git a/templates/python-scrapy/src/__init__.py b/templates/python-scrapy/src/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/templates/python-selenium/requirements.txt b/templates/python-selenium/requirements.txt index 89e74665..e26b2ce6 100644 --- a/templates/python-selenium/requirements.txt +++ b/templates/python-selenium/requirements.txt @@ -1,5 +1,5 @@ -# Add your dependencies here. -# See https://pip.pypa.io/en/latest/reference/requirements-file-format/ -# for how to format them +# Define your Python dependencies below. For formatting guidelines, refer to: +# https://pip.pypa.io/en/latest/reference/requirements-file-format/ + apify ~= 1.3.0 selenium ~= 4.14.0 diff --git a/templates/python-selenium/src/__init__.py b/templates/python-selenium/src/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/templates/python-selenium/src/__main__.py b/templates/python-selenium/src/__main__.py index 0b2cd323..ec715780 100644 --- a/templates/python-selenium/src/__main__.py +++ b/templates/python-selenium/src/__main__.py @@ -1,3 +1,10 @@ +""" +This module serves as the entry point for executing the Apify Actor. It handles the configuration of logging +settings. The `main()` coroutine is then executed using `asyncio.run()`. + +Feel free to modify this file to suit your specific needs. +""" + import asyncio import logging @@ -5,6 +12,7 @@ from .main import main +# Configure loggers handler = logging.StreamHandler() handler.setFormatter(ActorLogFormatter()) @@ -16,4 +24,5 @@ apify_logger.setLevel(logging.DEBUG) apify_logger.addHandler(handler) +# Execute the Actor main coroutine asyncio.run(main()) diff --git a/templates/python-selenium/src/main.py b/templates/python-selenium/src/main.py index 168e0507..75b43ff8 100644 --- a/templates/python-selenium/src/main.py +++ b/templates/python-selenium/src/main.py @@ -1,3 +1,12 @@ +""" +This module defines the `main()` coroutine for the Apify Actor, executed from the `__main__.py` file. + +Feel free to modify this file to suit your specific needs. + +To build Apify Actors, utilize the Apify SDK toolkit, read more at the official documentation: +https://docs.apify.com/sdk/python +""" + from urllib.parse import urljoin from selenium import webdriver @@ -11,7 +20,12 @@ # When running on the Apify platform, it is already included in the Actor's Docker image. -async def main(): +async def main() -> None: + """ + The main coroutine is being executed using `asyncio.run()`, so do not attempt to make a normal function + out of it, it will not work. Asynchronous execution is required for communication with Apify platform, + and it also enhances performance in the field of web scraping significantly. + """ async with Actor: # Read the Actor input actor_input = await Actor.get_input() or {} diff --git a/templates/python-start/requirements.txt b/templates/python-start/requirements.txt index 3aba82cb..a7617dd9 100644 --- a/templates/python-start/requirements.txt +++ b/templates/python-start/requirements.txt @@ -1,6 +1,7 @@ -# Add your dependencies here. -# See https://pip.pypa.io/en/latest/reference/requirements-file-format/ -# for how to format them +# Define your Python dependencies below. For formatting guidelines, refer to: +# https://pip.pypa.io/en/latest/reference/requirements-file-format/ + apify ~= 1.3.0 beautifulsoup4 ~= 4.12.2 -httpx ~= 0.25.0 +httpx ~= 0.25.2 +types-beautifulsoup4 ~= 4.12.0.7 diff --git a/templates/python-start/src/__init__.py b/templates/python-start/src/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/templates/python-start/src/__main__.py b/templates/python-start/src/__main__.py index aa649ea7..ec715780 100644 --- a/templates/python-start/src/__main__.py +++ b/templates/python-start/src/__main__.py @@ -1,3 +1,10 @@ +""" +This module serves as the entry point for executing the Apify Actor. It handles the configuration of logging +settings. The `main()` coroutine is then executed using `asyncio.run()`. + +Feel free to modify this file to suit your specific needs. +""" + import asyncio import logging @@ -5,7 +12,7 @@ from .main import main -# Set up logging of messages from the Apify SDK +# Configure loggers handler = logging.StreamHandler() handler.setFormatter(ActorLogFormatter()) @@ -17,4 +24,5 @@ apify_logger.setLevel(logging.DEBUG) apify_logger.addHandler(handler) +# Execute the Actor main coroutine asyncio.run(main()) diff --git a/templates/python-start/src/main.py b/templates/python-start/src/main.py index d1042499..b29dbd62 100644 --- a/templates/python-start/src/main.py +++ b/templates/python-start/src/main.py @@ -1,13 +1,29 @@ -# Beautiful Soup - library for pulling data out of HTML and XML files (Read more at https://www.crummy.com/software/BeautifulSoup/bs4/doc) +""" +This module defines the `main()` coroutine for the Apify Actor, executed from the `__main__.py` file. + +Feel free to modify this file to suit your specific needs. + +To build Apify Actors, utilize the Apify SDK toolkit, read more at the official documentation: +https://docs.apify.com/sdk/python +""" + +# Beautiful Soup - library for pulling data out of HTML and XML files, read more at +# https://www.crummy.com/software/BeautifulSoup/bs4/doc from bs4 import BeautifulSoup -# HTTPX - library for making asynchronous HTTP requests in Python (Read more at https://www.python-httpx.org/) + +# HTTPX - library for making asynchronous HTTP requests in Python, read more at https://www.python-httpx.org/ from httpx import AsyncClient -# Apify SDK - toolkit for building Apify Actors (Read more at https://docs.apify.com/sdk/python) +# Apify SDK - toolkit for building Apify Actors, read more at https://docs.apify.com/sdk/python from apify import Actor -async def main(): +async def main() -> None: + """ + The main coroutine is being executed using `asyncio.run()`, so do not attempt to make a normal function + out of it, it will not work. Asynchronous execution is required for communication with Apify platform, + and it also enhances performance in the field of web scraping significantly. + """ async with Actor: # Structure of input is defined in input_schema.json actor_input = await Actor.get_input() or {}