-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/rbx-libdev/ro.py into main
- Loading branch information
Showing
3 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from ro_py.utilities.errors import IncorrectKeyError, InsufficientCreditError, NoAvailableWorkersError | ||
from ro_py.captcha import UnsolvedCaptcha | ||
import requests_async | ||
import asyncio | ||
|
||
endpoint = "https://2captcha.com" | ||
|
||
|
||
class Task: | ||
def __init__(self): | ||
self.type = "FunCaptchaTaskProxyless" | ||
self.website_url = None | ||
self.website_public_key = None | ||
self.funcaptcha_api_js_subdomain = None | ||
|
||
def get_raw(self): | ||
return { | ||
"type": self.type, | ||
"websiteURL": self.website_url, | ||
"websitePublicKey": self.website_public_key, | ||
"funcaptchaApiJSSubdomain": self.funcaptcha_api_js_subdomain | ||
} | ||
|
||
|
||
class AntiCaptcha: | ||
def __init__(self, api_key): | ||
self.api_key = api_key | ||
|
||
async def solve(self, captcha: UnsolvedCaptcha): | ||
task = Task() | ||
task.website_url = "https://roblox.com" | ||
task.website_public_key = captcha.pkey | ||
task.funcaptcha_api_js_subdomain = "https://roblox-api.arkoselabs.com" | ||
|
||
data = { | ||
"clientKey": self.api_key, | ||
"task": task.get_raw() | ||
} | ||
|
||
create_req = await requests_async.post('https://api.anti-captcha.com/createTask', json=data) | ||
create_res = create_req.json() | ||
if create_res['errorId'] == 1: | ||
raise IncorrectKeyError("The provided anit-captcha api key was incorrect.") | ||
if create_res['errorId'] == 2: | ||
raise NoAvailableWorkersError("There are currently no available workers.") | ||
if create_res['errorId'] == 10: | ||
raise InsufficientCreditError("Insufficient credit in the 2captcha account.") | ||
|
||
solution = None | ||
while True: | ||
await asyncio.sleep(5) | ||
check_data = { | ||
"clientKey": self.api_key, | ||
"taskId": create_res['taskId'] | ||
} | ||
check_req = await requests_async.get("https://api.anti-captcha.com/getTaskResult", json=check_data) | ||
check_res = check_req.json() | ||
if check_res['status'] == "ready": | ||
solution = check_res['solution']['token'] | ||
break | ||
|
||
return solution |