Skip to content

Commit

Permalink
added anticaptcha & 2captcha example
Browse files Browse the repository at this point in the history
  • Loading branch information
iranathan committed Jan 18, 2021
1 parent b47bd16 commit cc19a16
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
17 changes: 17 additions & 0 deletions examples/anti_captcha_login.py
Original file line number Diff line number Diff line change
@@ -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())
17 changes: 17 additions & 0 deletions examples/twocaptcha_login.py
Original file line number Diff line number Diff line change
@@ -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())
2 changes: 0 additions & 2 deletions ro_py/extensions/anticaptcha.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit cc19a16

Please sign in to comment.