Asynchronous client for the ImageTyperz API
Project description
imagetyperz-async
An asynchronous client for the ImageTyperz CAPTCHA-solving API.
httpx powers the HTTP requests.
At the moment, only reCAPTCHAs are supported.
Installation
pip install imagetyperz-async
Usage
import asyncio
from imagetyperz import ImageTyperzClient, reCAPTCHAType
from imagetyperz.exceptions import NotDecoded
async def demo():
###
# Context manager will handle the closing of connections in the underlying
# httpx AsyncClient at block end.
#
# Alternatively, `await ita.aclose()` may be manually called to perform
# cleanup.
#
# If no cleanup is performed, a warning may be emitted at Python exit.
#
async with ImageTyperzClient('6F0848592604C9E14F0EBEA7368493C5') as ita:
print(await ita.retrieve_balance())
#: 8.8325
# Submit reCAPTCHA job
job_id = await ita.submit_recaptcha(
page_url='https://example.com/login',
site_key='scraped-site-key',
recaptcha_type=reCAPTCHAType.INVISIBLE,
)
print(job_id)
#: 176140709
# Check for results of the reCAPTCHA job
while True:
try:
g_response = await ita.retrieve_recaptcha(job_id)
except NotDecoded:
await asyncio.sleep(5)
continue
else:
print(g_response)
#: 03AGdBq25hDTCjOq4QywdrY...
break
# Alternatively, use complete_recaptcha to automatically handle the polling
# for results — returning with the result when ready.
g_response = await ita.complete_recaptcha(
page_url='https://example.com/login',
site_key='scraped-site-key',
recaptcha_type=reCAPTCHAType.INVISIBLE,
)
print(g_response)
#: 03AGdBq25hDTCjOq4QywdrY...
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for imagetyperz_async-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a38707b209887da936b98e0d72f1a3740468fc6b1730de1fd75421ee17775320 |
|
MD5 | 054feceda2aea20b5eacd52fc3e6596a |
|
BLAKE2b-256 | 7713a56d727723b9fef3291ed13174badc0a9aa2bbe465b21ebac463f8302db4 |