Skip to main content

A Python website bot development framework (WIP)

Introduction

This project was created to aid the development of website bots and API wrappers. aio-framework handles task management and execution, session management, and captcha queue management (with threads!). Currently, captcha queue management supports 2Captcha. aio-framework is meant to decrease development time by providing common bot and API wrapper functionality.

Basic Usage

This module is available via pip:

$ pip install aio-framework

Basic ApiWrapper and Bot implementations are shown below. Bot implementations must implement the execute_task method.

ApiWrapper

# exampleapiwrapper.py
from aio import ApiWrapper

class ExampleApiWrapper(ApiWrapper):
    BASE_URL = 'https://example.com'

    def get_product_data(self, product_url):
        response = self.get(product_url)
        return response.json()['data'] # Or something

    def add_product_to_cart(self, product_data, captcha_token):
        payload = {
            'product_data': product_data,
            'captcha': captcha_token
        }
        endpoint = '/add-to-cart'
        response = self.post(endpoint, data=payload)
        return response.json()['success'] # Or something

Bot

# examplebot.py
from aio import Bot
from aio.captcha import CaptchaManager
from exampleapiwrapper import ExampleApiWrapper

class ExampleBot(Bot):
    def execute_task(self, task):
        example_api_wrapper = ExampleApiWrapper()

        twocaptcha_api_token = '2CAPTCHA_API_TOKEN_HERE'
        site_key = 'SITE_KEY_HERE'
        page_url = 'PAGE_URL_HERE'

        captcha_manager = CaptchaManager(twocaptcha_api_token, site_key, page_url)
        captcha_manager.start_captcha_queue(num_threads=5)

        task.status = 'STARTED'

        product_url = task.data['product_url']

        task.logger.info('Getting product data')
        product_data = example_api_wrapper.get_product_data(product_url)
        task.logger.info('Got product data!')

        task.logger.info('Waiting for captcha token')
        captcha_token = captcha_manager.wait_for_captcha_token()
        task.logger.info('Got captcha token!')

        task.logger.info('Adding product to cart')
        added = example_api_wrapper.add_product_to_cart(product_data, captcha_token)
        task.logger.info('Added product to cart!')

        task.status = 'FINISHED'

Executing

# main.py
from aio import Task
from examplebot import ExampleBot

example_bot = ExampleBot()
task_data = {
    'product_url': 'https://example.com/product'
}
task = Task(task_data)
example_bot.add_task(task)
example_bot.start_all_tasks()

Metadata

Release files for aio-framework 0.0.5.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aio-framework 0.0.5.7
File Size Uploaded Provenance
aio-framework-0.0.5.7.tar.gz 5.1 kB Without provenance Details

Release files / aio-framework-0.0.5.7.tar.gz

Download URL aio-framework-0.0.5.7.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5a2c91ec568f34ad4cbf0868acdf025421b04ed87b0fa395ec73ee1ffa582f73
BLAKE2b-256 checksum
How to use checksums
1d87c4d95b304299977a968928299866b94a65a2a30ae2ab42da0ed43fdf4faa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for aio-framework 0.0.5.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.5.7 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page