Coder Social home page Coder Social logo

aio_anticaptcha's Introduction

Real-time captcha-to-text decodings for asyncio

image

image

image

API documentation

Installation

You can install it using Pip:

pip install aio_anticaptcha

If you want the latest development version, you can install it from source:

git clone [email protected]:nibrag/aio_anticaptcha.git
cd aio_anticaptcha
python setup.py install

Requirements:

python 3.4+
aiohttp

Usage

With context manager

import asyncio
from aio_anticaptcha import AntiCaptcha, ServiceError

async def run(loop):
    try:
        with AntiCaptcha('API-KEY', loop=loop) as ac:
            # io.IOBase
            fh = open('captcha.jpg')
            resolved, captcha_id = await ac.resolve(fh)

            # or bytes, bytearray
            bytes_buff = open('captcha.jpg', 'rb').read()
            resolved, captcha_id = await ac.resolved(bytes_buff)
    except ZeroBalanceError:
        print('Zero balance')
    except UserKeyError:
        print('Invalid api key...')
    except ServiceError as e:
        print('Something else', str(e))

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(run(loop))
    loop.close()

Without context manager

import asyncio
from aio_anticaptcha import AntiCaptcha, ServiceError

async def run(loop):
    ac = AntiCaptcha('API-KEY', loop=loop)
    try:
        # io.IOBase
        resolved, captcha_id = await ac.resolve(open('captcha.jpg'))

        # or bytes, bytearray
        bytes_buff = open('captcha.jpg', 'rb').read()
        resolved, captcha_id = await ac.resolved(bytes_buff)
    except ServiceError as e:
        print(e)
    finally:
        # do'nt forget call close method
        ac.close()

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(run(loop))
    loop.close()

If you wish to complain about a mismatch results, use abuse method:

import asyncio
from aio_anticaptcha import AntiCaptcha

async def run(loop):
    with AntiCaptcha('API-KEY', loop=loop) as ac:
        resolved, captcha_id = await ac.resolve(open('captcha.jpg'))
        await ac.abuse(captcha_id)

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(run(loop))
    loop.close()

After all manipulations, you can get your account balance:

import asyncio
from aio_anticaptcha import AntiCaptcha

async def run(loop):
    with AntiCaptcha('API-KEY', loop=loop) as ac:
        balance = await ac.get_balance()

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(run(loop))
    loop.close()

Additional options for sending Captcha:

Read documentation about all available options: https://anti-captcha.com/apidoc

import asyncio
from aio_anticaptcha import AntiCaptcha

async def run(loop):
    with AntiCaptcha('API-KEY', loop=loop) as ac:
        resolved, captcha_id = await ac.resolve(open('captcha.jpg'), max_len=5, is_russian=True)

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(run(loop))
    loop.close()

Customizing anticaptcha service

import asyncio
from aio_anticaptcha import AntiCaptcha

async def run(loop):
    with AntiCaptcha('API-KEY', loop=loop, domain='antigate.com', port=80) as ac:
        balance = await ac.get_balance()

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(run(loop))
    loop.close()

AntiGate.com supported

import asyncio
from aio_anticaptcha import AntiGate

async def run(loop):
    with AntiGate('API-KEY', loop=loop) as ag:
        balance = await ag.get_balance()

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(run(loop))
    loop.close()

aio_anticaptcha's People

Contributors

nibrag avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.