TwoCaptcha - Wrapper is a wrapper for the 2Captcha API (Recaptcha V2 Token method only) that solves your CAPTCHA with high accuracy.
pip install twocaptcha
git clone https://github.com/tiagocardosoweb/twocaptcha-wrapper.git
cd twocaptcha
python setup.py install
First you need a 2Captcha Account, you can Register Here, after register your account:
- Login into your account.
- Add some money.
- Go to "2Captcha API"
- Get "CAPTCHA Key"
from twocaptcha import TwoCaptcha
two= TwoCaptcha(<api_key>, <soft_id=None>, <log=None>)
print two.get_balance()
This function will return your account balance (string).
from twocaptcha import TwoCaptcha
two = TwoCaptcha(<api_key>, <soft_id=None>, <log=None>)
print two.upload(<google_key>,<page_url>)
This function will upload the captcha request and then return the request ID (string).
from twocaptcha import TwoCaptcha
two = TwoCaptcha(<api_key>, <soft_id=None>, <log=None>)
print two.get_response(<request_id>,<except=False>)
This function will request the token from the a request and return you the resolution token (string).
**NOTE:** If you want the method to raise an exception in case something goes wrong, set <except> to *True*
from twocaptcha import TwoCaptcha
two = TwoCaptcha(<api_key>, <soft_id=None>, <log=None>>)
print two.resolve_captcha(<google_key>,<page_url>,<waittime=15>)
This function will upload the captcha request & ask back the captcha solution and return the token (string).
*How it works?* 15 seconds timeout + (5 seconds timeout * while token is not returned )
from twocaptcha import TwoCaptcha
two = TwoCaptcha(<api_key>, <soft_id=None>, <log=None>, <extra_data_file_path=None>)
print two.upload(<google_key>,<page_url>,<pingback_url>)
This function will upload the captcha request and then return it via a POST request to your Pingback URL.
from twocaptcha import TwoCaptcha
two = TwoCaptcha(<api_key>, <soft_id=None>, <log=None>, <extra_data_file_path=None>)
print two.add_pingback(<url>)
from twocaptcha import TwoCaptcha
two = TwoCaptcha(<api_key>, <soft_id=None>, <log=None>)
print two.add_pingback(<url>)
from twocaptcha import TwoCaptcha
two = TwoCaptcha(<api_key>, <soft_id=None>, <log=None>)
print two.delete_pingback(<url=None>, <all=False>)
You must provie and URL or set <all> to *True*
from twocaptcha import TwoCaptcha
two = TwoCaptcha(<api_key>, <soft_id=None>, <log=Log Here>)
print two.complain(<request_id>)
from twocaptcha import TwoCaptcha
two = TwoCaptcha(<api_key>, <soft_id=None>, <log=Log Here>)
print two.getbalance()
All methods throw up exceptions, so be sure to import them
from twocaptcha import AccessDeniedException
- AccessDeniedException
- CaptchaException
- BalanceException
- PingbackException
- KeyException