From cc19a16995b6c9bc09e0e87ea95119d9db354618 Mon Sep 17 00:00:00 2001 From: iranathan Date: Mon, 18 Jan 2021 11:07:06 +0100 Subject: [PATCH] added anticaptcha & 2captcha example --- examples/anti_captcha_login.py | 17 +++++++++++++++++ examples/twocaptcha_login.py | 17 +++++++++++++++++ ro_py/extensions/anticaptcha.py | 2 -- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 examples/anti_captcha_login.py create mode 100644 examples/twocaptcha_login.py diff --git a/examples/anti_captcha_login.py b/examples/anti_captcha_login.py new file mode 100644 index 00000000..208139d6 --- /dev/null +++ b/examples/anti_captcha_login.py @@ -0,0 +1,17 @@ +from ro_py.client import Client +from ro_py.extensions.anticaptcha import AntiCaptcha +import asyncio + +client = Client() +captcha = AntiCaptcha("ANTI CAPTCHA API KEY") + + +async def main(): + unsolved_captcha = await client.user_login("username", "password") + solved = await captcha.solve(unsolved_captcha) + await client.user_login("username", "password", token=solved) + me = await client.get_self() + print(f"logged in as {me.name} with id {me.id}") + + +asyncio.run(main()) diff --git a/examples/twocaptcha_login.py b/examples/twocaptcha_login.py new file mode 100644 index 00000000..4d3e3d7b --- /dev/null +++ b/examples/twocaptcha_login.py @@ -0,0 +1,17 @@ +from ro_py.client import Client +from ro_py.extensions.anticaptcha import TwoCaptcha +import asyncio + +client = Client() +captcha = TwoCaptcha("ANTI CAPTCHA API KEY") + + +async def main(): + unsolved_captcha = await client.user_login("username", "password") + solved = await captcha.solve(unsolved_captcha) + await client.user_login("username", "password", token=solved) + me = await client.get_self() + print(f"logged in as {me.name} with id {me.id}") + + +asyncio.run(main()) diff --git a/ro_py/extensions/anticaptcha.py b/ro_py/extensions/anticaptcha.py index 10a61c68..f83ada8f 100644 --- a/ro_py/extensions/anticaptcha.py +++ b/ro_py/extensions/anticaptcha.py @@ -46,7 +46,6 @@ async def solve(self, captcha: UnsolvedCaptcha): if create_res['errorId'] == 10: raise InsufficientCreditError("Insufficient credit in the 2captcha account.") - print(create_res) solution = None while True: await asyncio.sleep(5) @@ -56,7 +55,6 @@ async def solve(self, captcha: UnsolvedCaptcha): } check_req = await requests_async.get("https://api.anti-captcha.com/getTaskResult", json=check_data) check_res = check_req.json() - print(check_res, "@") if check_res['status'] == "ready": solution = check_res['solution']['token'] break